CentOS9 \ Centos8安装MySQL 8步骤

centos8 rpm 安装mysql8.0.28_太阳神LoveU的博客-CSDN博客

This upper link is still working for mysql 8 on the CentOS 8 and the CentOS 9 Stream Edition, it is advised.

The below is old and may not work.

========It may not work below, visit the upper link to get the correct step for MySQL8=========

一、安装mysql

#// 1.  更新软件
yum update

#// 2. 下载mysql,保证网络连通
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

#// 3. 下载mysql,保证网络连通
rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

#// 4. 下载mysql,保证网络连通
yum module disable mysql

#// 5. 下载mysql,保证网络连通
yum install mysql-community-server

#// 6. 启动mysql
service mysqld start

#// 7. 查看状态
service mysqld status

#// 8. 查看默认密码,找个地方记住一会要登陆
grep 'temporary password' /var/log/mysqld.log

#// 9. 进入mysql
mysql -u root -p

#// 10. 更改密码规则,即可以设置root等密码
set global validate_password.length=4

#// 11. 更改密码规则,即可以设置root等密码
set global validate_password.policy=0

#// 12. 更改密码规则,即可以设置root等密码
set global validate_password.check_user_name = 0

#// 13. 设置密码为root
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root'

#// 14. 刷新
flush privileges

#// 15. 使用mysql
use mysql

#// 16. 查询
select host, user from user

#// 17. 修改localhost,以便主机连接
update user set host = '%' where user = 'root'

#// 18. 刷新
flush privileges

#// 19. 设置root权限
GRANT ALL ON *.* TO 'root'@'%' 

#// 20. 刷新
flush privileges

#// 21. 退出
exit

#// 22. 重启mysql
service mysqld restart

二、注意事项

1、skip-grant-tables 当mysql没有密码或者不知道密码时,添加在my.cnf(/etc/my.cnf)的[mysqld]下面,可以跳过密码验证,但是当改好密码之后把它注释,不然远程连数据库报错2013。

2、操作数据库,更改添加之后flush privileges;刷新。

posted @ 2022-03-02 20:12  太阳神LoveU  阅读(81)  评论(0编辑  收藏  举报  来源