CentOS安裝配置MySql數據庫
CentOS版本7.2,MySql版本5.7
1、下載MySql安裝源
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
2、安裝MySql源
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
3、安裝MySql
yum install mysql-community-server -y
4、啟動MySql
systemctl start mysqld.service 或者 service mysqld restart
5、修改密碼
MySQL5.7加強了root用戶的安全性,因此在第一次安裝後會初始化一個隨機密碼,以下為查看初始隨機密碼的方式
grep ‘temporary password‘ /var/log/mysqld.log grep命令使用教程
結果如下:
使用初始隨機密碼登錄後MySQL會強制要求修改密碼,否則無法正常使用,(密碼必須包含小寫、大寫字母及特殊字符,當然也有其他方法不受此限制,再次不多做描述),修改方法如下:
SET PASSWORD = PASSWORD(‘your new password‘); ALTER USER [email protected]
然後退出後即可用新密碼登錄。
6、遠程連接授權
MySql是根據mysql數據庫中的user表裏面host字段來做ip鑒權的,[email protected],也可以指定IP地址。
use mysql;
update set user [email protected] where user=‘root‘;
7、開通3306端口
開通端口後需要重啟防火墻,firewalld使用參考
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
以上參考http://www.cnblogs.com/longrui/p/6071581.html
CentOS安裝配置MySql數據庫