停止MySQL服务
systemctl stop mariadb.servicesystemctl stop mysqld
禁止MySQL服务开机自启
systemctl disable mysqld
卸载MySQL软件包
yum remove mysql-server mysql-client
删除MySQL数据目录
rm -rf /var/lib/mysql
清理MySQL配置文件
rm -rf /etc/my.cnf
rpm -qa | grep mysql/mariadb
卸载这些默认安装包
sudo rpm -e --nodeps mysql...
选择合适的版本:mysql57-community-release-el7-9.noarch
查看当前yum源
ls /etc/yum.repos.d/ -al
安装MySQL官方yum源
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
看看能不能正常⼯作
yum list | grep mysql
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022yum install -y mysql-community-server
ls /etc/my.cnfwhich mysqldwhich mysql
systemctl start mysqld.service
临时密码登录
grep 'temporary password' /var/log/mysqld.logmysql -u root -p
注意:新版本的MySQL没有临时密码,可以直接登录
配置文件免密码登录
vim /etc/my.cnf在最后一行添加skip-grant-tables
systemctl restart mysqld 重启服务mysql -u root -p 直接回车即可登录
systemctl enable mysqldsystemctl daemon-reload
配置⼀下my.conf,主要是数据库客⼾端和服务器的编码格式
vim /etc/my.cnf末尾添加以下两行character-set-server=utf8default-storage-engine=innodb
来源地址:https://blog.csdn.net/ikun66666/article/details/131937245