新聞中心
第一部分:centos 7安裝mysql 5.7

1.下載yum庫
shell > wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
2.安裝YUM庫
shell > yum localinstall -y mysql57-community-release-el7-7.noarch.rpm
3.安裝數(shù)據(jù)庫
shell > yum install -y mysql-community-server
4.啟動MySQL服務(wù)
shell > systemctl start mysqld.service
5.默認空密碼
shell > mysql -uroot -p
6.重置root密碼后重啟mysql服務(wù)
shell > update mysql.user set authentication_string=password("yourpassword") where user="root" and Host="localhost";
shell > flush privileges;
shell > quit;
shell > systemctl restart mysqld;
如果手賤或者不知道啥原因出現(xiàn)如下問題:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
請修改my.cnf,添加skip-grant-tables和skip-networking:
shell > vi /etc/my.cnf
[mysqld]
skip-grant-tables
skip-networking
重啟mysql,然后重復(fù)以上修改密碼步驟即可,記得修改完后,去掉my.cnf添加的兩行。
第二部分:配置
1、添加遠程登錄用戶(登入Mysql)
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你的密碼' WITH GRANT OPTION;
注:'%'代表任意地址,也可以指定IP
2、檢查用戶表,刷新內(nèi)存權(quán)限
select host, user from user;
FLUSH PRIVILEGES;
3、設(shè)置防火墻(CentOS7 不推薦)
vi /etc/sysconfig/iptables
在-A RH-Firewall-1-INPUT -j REJECT –reject-with icmp-host-prohibited之前,添加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
重啟防火墻
service iptables restart
注:centos7使用的是firewall防火墻
systemctl stop firewalld.service #停止
systemctl disable firewalld.service #禁用
4、設(shè)置字符編碼集和區(qū)分大小寫
4.1修改mysql配置文件(設(shè)置字符編碼集)
默認位置:/etc/my.cnf
進入etc文件夾>>vim my.cnf
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
* systemctl restart mysql.service #重啟MySQL
* 查看當前mysql運行狀態(tài)
mysql>status
參數(shù)說明:
haracter_set_client:客戶端請求數(shù)據(jù)的字符集。
character_set_connection:從客戶端接收到數(shù)據(jù),然后傳輸?shù)淖址?/p>
character_set_database:默認數(shù)據(jù)庫的字符集,無論默認數(shù)據(jù)庫如何改變,都是這個字符集;如果沒有默認數(shù)據(jù)庫,使character_set_server指定的字符集,此參數(shù)無需設(shè)置。
character_set_filesystem:把操作系統(tǒng)上文件名轉(zhuǎn)化成此字符集,即把character_set_client轉(zhuǎn)換character_set_filesystem,默認binary即可。
character_set_results:結(jié)果集的字符集。
character_set_server:數(shù)據(jù)庫服務(wù)器的默認字符集。
character_set_system:這個值總是utf8,不需要設(shè)置,存儲系統(tǒng)元數(shù)據(jù)的字符集。
4.2修改mysql配置文件(設(shè)置區(qū)分大小寫)
lower_case_table_names 參數(shù)詳解:
0:區(qū)分大小寫
1:不區(qū)分大小寫
下面看下修改后的預(yù)覽圖:
以上是經(jīng)過自己實踐后記錄的,若有疑問歡迎各位留言討論!
新聞名稱:CentOS7下yum成功安裝MySQL5.7
文章網(wǎng)址:http://www.dlmjj.cn/article/ccoijdg.html


咨詢
建站咨詢
