歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> Linux Centos 7 使用yum安裝 mysql5.7 (實驗成功),centosmysql5.7

Linux Centos 7 使用yum安裝 mysql5.7 (實驗成功),centosmysql5.7

日期:2017/3/6 9:20:21   编辑:學習Linux

Linux Centos 7 使用yum安裝 mysql5.7 (實驗成功),centosmysql5.7


Linux Centos 7 使用yum安裝 mysql5.7 (實驗成功),centosmysql5.7


第一部分:安裝Mysql5.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.安裝數據庫 shell > yum install -y mysql-community-server

4.啟動MySQL服務

shell > systemctl start mysqld.service

5.默認空密碼

shell > mysql -uroot -p

6.重置root密碼後重啟mysql服務

shell > update mysql.user set authentication_string=password("yourpassword") where user="root" and Host="localhost";

shell > flush privileges;

shell > quit;

shell > systemctl restart mysqld;

如果手賤或者不知道啥原因出現如下問題:

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,然後重復以上修改密碼步驟即可,記得修改完後,去掉my.cnf添加的兩行。

第二部分:配置

1、添加遠程登錄用戶(登入Mysql) use mysql; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你的密碼' WITH GRANT OPTION; 注:'%'代表任意地址,也可以指定IP 2、檢查用戶表,刷新內存權限 select host, user from user; FLUSH PRIVILEGES; 3、設置防火牆(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、設置字符編碼集和區分大小寫 4.1修改mysql配置文件(設置字符編碼集) 默認位置:/etc/my.cnf 進入etc文件夾>>vim my.cnf [mysqld] character-set-server=utf8 collation-server=utf8_general_ci * systemctl restart mysql.service #重啟MySQL * 查看當前mysql運行狀態 mysql>status 參數說明: haracter_set_client:客戶端請求數據的字符集。 character_set_connection:從客戶端接收到數據,然後傳輸的字符集。 character_set_database:默認數據庫的字符集,無論默認數據庫如何改變,都是這個字符集;如果沒有默認數據庫,使character_set_server指定的字符集,此參數無需設置。 character_set_filesystem:把操作系統上文件名轉化成此字符集,即把character_set_client轉換character_set_filesystem,默認binary即可。 character_set_results:結果集的字符集。 character_set_server:數據庫服務器的默認字符集。 character_set_system:這個值總是utf8,不需要設置,存儲系統元數據的字符集。 4.2修改mysql配置文件(設置區分大小寫) lower_case_table_names 參數詳解: 0:區分大小寫 1:不區分大小寫 下面看下修改後的預覽圖: 以上是經過自己實踐後記錄的,若有疑問歡迎各位留言討論!

http://xxxxxx/Linuxjc/1154889.html TechArticle

Copyright © Linux教程網 All Rights Reserved