天天看點

CentOS 7 安裝MySQL

由于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