CentOS 7的yum源中沒有正常安裝mysql時的mysql-sever文件,須要去官網上下載mysql
下載連接:http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpmsql
或直接下載:shell
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
安裝:spa
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server
若安裝不了則執行:
rest
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server
成功安裝以後啓動mysql:
code
# service mysqld restart
初次安裝mysql是root帳戶是沒有密碼的,設置密碼:server
# mysql -uroot
mysql> set password for ‘root’@‘localhost’ = password('mypasswd');
----------------------------------------------------------------------------------------get
因爲mysql安裝以後,root帳號的host都只有本地的it
因此須要建立一個能夠由任意host登陸的root帳號:class
mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'password';
爲帳號 'root'@'%' 授予全部權限:
mysql> GRANT ALL ON *.* TO 'root'@'%';
這樣就擁有一個能夠遠程登陸的root帳號了!