1、先删除CentOS7默认安装的是mariadb数据库
1、查询是否安装yum search mysql
2、移除mariadb数据库 yum remove mariadb-libs.x86_64
2、下载MySQL源
打开MySQL官网
3、安装
cd ~
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
yum localinstall mysql57-community-release-el7-11.noarch.rpm
查看一下:yum list|grep mysql-community-server
yum install mysql-community-server
4、设置
1、启动MySQL
systemctl start mysqld
2、找到默认密码
cat /var/log/mysqld.log | grep password
3、进入数据库
mysql -uroot -pkw4u*\!uaMr0,
4、若想设置简单密码:
执行:set global validate_password_policy=0;
执行:set global validate_password_length=1;
执行:SET PASSWORD = PASSWORD('123456');
此时,密码设置完成,密码为123456
5、开启远程连接
执行:mysql -uroot –p123456进入MySQL
执行:show databases;
执行:use mysql;
执行:select Host,User from user \G;
执行:update user set Host = '%' where Host = 'localhost' and User = 'root';
执行:select Host,User from user \G; 查看是否更改
执行:flush privileges; 或者重启mysql服务器
此时,Navicat就可以远程访问数据库了