CentOS 7 安装 MySql8.0

 

1-配置 Yum 库

rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm

2-安装 MySql

2.1 禁用mysql repo文件中的所有存储库

sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo

2.2 根据操作系统执行以下命令之一以安装MySQL

yum --enablerepo=mysql80-community install mysql-community-server 

3-服务启动

3.1 使用 SysVinit 命令

service mysqld start

3.2 使用Systemd 命令

systemctl start mysqld.service

4-查找默认root账户密码

grep "A temporary password" /var/log/mysqld.log

5-MySql Post 安装设置,执行一下命令,然后所有都回复y

mysql_secure_installation
扫描二维码关注公众号,回复: 7111896 查看本文章

6-重启和开启MySql 服务

### Using SysVinit
service mysqld restart
chkconfig mysqld on

### Using Systemd
systemctl restart mysqld.service
systemctl enable mysqld.service

7-登陆MySql

mysql -h localhost -u root -p

7.1 创建用户

CREATE USER 'lyra'@'%' IDENTIFIED BY 'xxxx';

7.2 用户授权

GRANT ALL PRIVILEGES ON *.* TO 'lyra'@'%' WITH GRANT OPTION;

7.3 授权NAVICAT客户端链接

ALTER USER 'lyra'@'%' IDENTIFIED WITH mysql_native_password BY 'xxxx'; 
FLUSH PRIVILEGES;

7.4 使命令生效

FLUSH PRIVILEGES;

7.5 修改密码

PS: 不需要flush privileges来刷新权限

ALTER user 'root'@'localhost' IDENTIFIED BY 'XXXX'

 8-参考地址

 参考地址:https://tecadmin.net/install-mysql-8-on-centos/

 
 

猜你喜欢

转载自www.cnblogs.com/ganqiyin/p/11420268.html