卸载mariadb
# 查看mariadb安装包
rpm -qa | grep mariadb
# 卸载
rpm -e 查看mariadb安装包 --nodeps
- 解压
mkdir tmp
tar vxf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar -C ./tmp
- 安装
cd tmp
rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-devel-8.0.18-1.el7.x86_64.rpm
- 初始化、授权和开启mysql服务
mysqld --initialize
chown mysql:mysql /var/lib/mysql -R
systemctl start mysqld
- 查看root初始密码, 登录修改密码
cat /var/log/mysqld.log | grep password
mysql -u root -p
ALTER USER "root"@"localhost" IDENTIFIED BY "自己的密码";
FLUSH PRIVILEGES;
- 允许远程连接
use mysql;
update user set host = '%' where user ='root';
ALTER USER 'root'@'%' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '自己的密码';