新版CentOS 8.x安装MySql5.7

2022-06-13 12:49:51

CentOS安装MySql5.7

最新的CentOS8也是可以用此方法安装的。
centos8
1、下载yum包

wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm

2、安装MySQL源

rpm -Uvh mysql57-community-release-el7-10.noarch.rpm

3、安装MySQL服务端

yuminstall -y mysql-community-server

如果此步报错,先执行yum module disable mysql
再执行yum install -y mysql-community-server

4、启动MySQL服务

systemctl start mysqld.service

可用systemctl status mysqld.service查看启动状态
查看启动状态
5、查看临时密码,并登陆修改密码

grep'temporary password' /var/log/mysqld.log

密码
OkquA5bw:eGU

mysql-u root-p
Enter password: OkquA5bw:eGU(这里用刚才得到的临时密码)-- 更改一遍设置简单密码setglobal validate_password_policy=0;setglobal validate_password_length=1;-- 修改密码ALTERUSER'root'@'localhost' IDENTIFIED BY '在此处替换为你的密码';
-- 添加远程访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '在此处替换为你的密码'WITHGRANTOPTION;-- 使更改生效
FLUSHPRIVILEGES;

示例:
示例
6、设置开机启动
使用Ctrl + D 退出MySql

systemctlenable mysqld
systemctl daemon-reload

7、将字符集设置为UTF-8

vim /etc/my.cnf

在下图所示位置添加

[mysql]
default-character-set=utf8

character_set_server=utf8

示例
8、重启MySql

service mysqld restart
  • 作者:皮卡皮卡~
  • 原文链接:https://blog.csdn.net/y_universe/article/details/108776455
    更新时间:2022-06-13 12:49:51