码迷,mamicode.com
首页 > 数据库 > 详细

CentOS7.X yum安装MySQL8.0

时间:2021-06-07 20:40:56      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:lte   state   mysqld   默认   x86_64   emc   mod   unit   image   

查看当前系统版本的详细信息

# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)

yum源下载

地址:https://dev.mysql.com/downloads/repo/yum/
技术图片

下载地址:https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm

下载完成后使用yum命令本地安装yum源

# yum localinstall mysql80-community-release-el7-3.noarch.rpm
# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64    MySQL Connectors Community               95
mysql-tools-community/x86_64         MySQL Tools Community                    84
mysql80-community/x86_64             MySQL 8.0 Community Server               82

安装MySQL

#  yum install -y mysql-community-server
# systemctl start mysqld

修改默认数据存储路径

默认存储路径是/var/lib/mysql,修改成/data/mysql

systemclt stop mysqld.service
mkdir /data/mysql
cp -a -R /var/lib/mysql/* /data/mysql/
chown mysql:mysql /data/mysql/
chmod 750 /data/mysql/

vim /ect/my.cnf
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock

datadir=/data/mysql
socket=/data/mysql/mysql.sock

systemctl start mysqld

# 用户登录。mysql -uroot -p 输入密码,提示错误。SQLSTATE[HY000] [2002] Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘
ln -s /data/mysql/mysql.sock /var/lib/mysql/mysql.sock

MySQL常用命令

systemctl start mysqld
systemctl status mysqld

/var/log/mysqld.log找到root默认密码(有日志生成情况下)

# grep ‘temporary password‘ /var/log/mysqld.log

修改密码

ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘eSem?a?ap‘;
flush privileges;

CentOS7.X yum安装MySQL8.0

标签:lte   state   mysqld   默认   x86_64   emc   mod   unit   image   

原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/14858366.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!