rpm -aq | grep mysql | xargs rpm -e --nodeps ( 卸载应用同时卸载掉相关联的缓存 )
rpm -aq | grep mariadb | xargs rpm -e --nodeps
rm -rf find / -name mysql
rpm -ivh mysql-community-common-8.0.22-1.el8.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-8.0.22-1.el8.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-client-8.0.22-1.el8.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-server-8.0.22-1.el8.x86_64.rpm --force --nodeps
rpm -aq|grep mysql
mysql --initialize
chown -R mysql:mysql /var/lib/mysql/
systemctl start mysqld (一般我喜欢使用restart 进行重启mysql)
cat /var/log/mysqld.log | grep password (注意不要带空格)
mysql_secure_installation
### 补充指令 # 启动数据库 systemctl start mysqld # 关闭数据库 systemctl stop mysqld # 重启数据库 systemctl restart mysqld # 查看数据库状态 systemctl status mysqld # 进入mysql mysql -u root -p'密码'
### 授予远程连接权限 create user 'root'@'%' identified by '123456'; grant all on *.* to `root`@`%` WITH GRANT OPTION; ALTER USER 'root'@'%' IDENTIFIED with mysql_native_password by '123456'; flush privileges;