在linux 平台可以多种方式安装 MySQL :
详细文档 : https://blog.csdn.net/u010476739/article/details/100083959
yum install mysql-server
启动服务
systemctl start mysqld
停止
systemctl stop mysqld
查看状态
systemctl status mysqld
如果之前安装过 MySql 先删除
yum remove mysqld
删除 /var/lib目录下的mysql目录 避免初始化失败
rm -rf /var/lib/mysql
1. 查看初始化密码
grep "password" /var/log/mysqld.log
# A temporary password is generated for root@localhost: gHHHpJl
2. 连接 mysql
mysql -u root - p
passwowd:输入临时密码
# 成功连接
注意密码强度!
## 8.4 前 MYSQL_NATIVE_PASSWORD
ALTER USER 'root'@'localhost' IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY '新密码';
# ALTER USER 'root'@'localhost' IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY '35%TGh&*90';
## 8.4 新版本 caching_sha2_password
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '新密码';
刷新权限
FLUSH PRIVILEGES;