1.卸载CentOS7默认数据库mariadb
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
2.安装,启动mysql
cd /opt/
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
cd /etc/yum.repos.d/
yum install mysql-server -y --nogpgcheck
systemctl start mysqld
3.登录MySql
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
exit;
4.修改etc文件夹下的my.cnf文件
vim /etc/my.cnf
socket下添加:
skip-grant-tables
character_set_server=utf8
init_connect='SET NAMES utf8'
systemctl restart mysqld
5.更改密码并允许远程登录
mysql -uroot -p
use mysql;
flush privileges;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'ok';
update user set Host='%' where User='root';
flush privileges;
exit;
6.测试连接
|