centos7參考:http://www.cnblogs.com/starof/p/4680083.html
mysql-community-release包下載下傳連接配接:http://files.cnblogs.com/files/amusic/mysql-community-release-el7-5.noarch.zip
以下為centos6環境,
#以下這條指令是解決雲模闆中的MariaDB與MySQL相關軟體包沖突問題
yum remove MariaDB* -y
#安裝啟動MySQL資料庫伺服器
yum install mysql-server -y
#
service mysqld start
#設定資料庫管理者初始密碼為password
mysqladmin -u root password 'password'
#開啟防火牆資料庫相關端口
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
service iptables save
#如果使用的是MariaDB,以下指令改為chkconfig mysql on
chkconfig mysqld on
使用mysql工具連接配接失敗:
一:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor
更新權限
#登入mysql
mysql -uroot -ppassword
#切換資料庫
>use mysql;
>update user set password=password('newpassword') where user='root';
#更新權限
>flush privileges;
>quit
二:
1130 - host is not allowed to connect to this mysql server
未開啟遠端連接配接
解決方案:
#使用root登入mysql
mysql -uroot -ppassword
>use mysql;
#更改user表
>update user set host = '%' where user = 'root';
#驗證結果
>select host, user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| 127.0.0.1 | root |
| centos | |
| centos | root |
| localhost | |
+-----------+------+
5 rows in set (0.00 sec)
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5iY3QjZlVmN4gjYiJjYiF2NiZTNlJjNzIWZiFjN1EWN28CX0JXZ252bj91Ztl2Lc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)