当前位置:Gxlcms > 数据库问题 > CentOS7.X yum安装MySQL8.0

CentOS7.X yum安装MySQL8.0

时间:2021-07-01 10:21:17 帮助过:5人阅读

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

# 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   

人气教程排行