在centos7.3中安裝mysql5.6
阿新 • • 發佈:2018-12-12
接上文,開始安裝mysql5.6。
- 通過yum線上安裝mysql
- 如果沒有安裝yum-utils包,執行命令
yum -y install yum-utils
- 檢測系統是否自帶安裝mysql
yum list installed | grep mysql
- 刪除系統自帶的mysql及其依賴
yum -y remove mysql-libs.x86_64
- 給CentOS新增rpm源,並且選擇較新的源
# wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm # yum localinstall mysql-community-release-el6-5.noarch.rpm 檢視mysql安裝源 # yum repolist all | grep mysql 禁用低版本安裝源 # yum-config-manager --disable mysql55-community 開啟高版本安裝源 # yum-config-manager --enable mysql56-community # yum-config-manager --enable mysql57-community-dmr 檢視已開啟版本安裝源 # yum repolist enabled | grep mysql
- 安裝mysql伺服器
yum install mysql-community-server
- 啟動mysql
service mysqld start
- 登入mysql
mysql -uroot -p 不需要輸入密碼 SET PASSWORD = PASSWORD('ieforever');
- 設定遠端訪問:
1.建立使用者 create user 'crbchqimis'@'%' identified by 'crbchqimis'; 2.賦予許可權 grant all privileges on *.* to 'crbchqimis' @'%' identified by 'crbchqimis'; grant all privileges on *.* to 'crbchqimis' @'localhost' identified by 'crbchqimis'; 3.重新整理許可權 flush privileges;
- 檢視使用者
use mysql; SELECT DISTINCT CONCAT('User: [', user, '''@''', host, '];') AS USER_HOST FROM user; +------------------------------------+ | USER_HOST | +------------------------------------+ | User: [ieforever'@'%]; | | User: [mysql.session'@'localhost]; | | User: [mysql.sys'@'localhost]; | | User: [root'@'localhost]; | +------------------------------------+
- 設定編碼和不區分大小寫
以上mysql5.6已經安裝成功,下面開啟訪問埠:vim /etc/my.cnf 在[mysqld] 下新增 lower_case_table_names=1 character_set_server=utf8 重啟服務 service mysqld restart
- 檢視已開放的埠(預設不開放任何埠) firewall-cmd --list-ports
- 開啟3306埠 firewall-cmd --zone=public(作用域) --add-port=3306/tcp(埠和訪問型別) --permanent(永久生效)
- 重啟防火牆 firewall-cmd --reload