由于MySQL被Oracle收购以后,CentOS默认yum库内置的数据库由原来的MySQL改为了MariaDB。
为了安装MySQL,我们需要将MySQL官方的Repo加到CentOS的repo里面。
在CentOS命令行,运行
将其添加到yum库。
运行
sudo yum install mysql-server
安装MySQL
启动MySQL。将上面命令的start,替换为stop,restart,status,对应原来的MySQL服务命令。
-------------------------
[root@localhost mysql]# mysql -u root mysql
mysql> use mysql;
mysql> desc user;
mysql> update user set Password = password('123123') where User='root'; //设置root用户密码
mysql> select Host,User,Password from user where User='root';
mysql> flush privileges;
mysql> exit
重新登录
[root@localhost mysql]# mysql -u root -p
Enter password:123123
若还不能进行远程连接,关闭防火墙
[root@localhost]# systemctl stop firewalld.service