這篇文章主要為大家詳細介紹了Centos7.3下mysql5.7安裝配置教程,具有一定的參考價值,有興趣的小伙伴們可以參考一下
本文大家分享了mysql5. 7安裝設定教程,供大家參考,具體內容如下
第一步:取得mysql YUM來源
#進入mysql官網取得RPM包下載位址
點擊下載
#右鍵複製連結位址##
https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
第二步:下載和安裝mysql來源
先下載mysql來源安裝套件[root@localhost ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
yum -y install wget
wgethttps://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
#
yum -y localinstall mysql57-community-release-el7-11.noarch.rpm
第三步:線上安裝Mysql
yum -y install mysql-community-server
第四步:啟動Mysql服務
systemctl start mysqld
第五步:設定開機啟動
#
[root@localhost ~]# systemctl enable mysqld [root@localhost ~]# systemctl daemon-reload
修改root本機登入密碼mysql安裝完成之後,在/var/log/mysqld.log檔案中給root產生了一個暫時的預設密碼。
[root@localhost ~]# vi /var/log/mysqld.log
這裡的臨時密碼eMV.R#mWe3ha
[root@localhost ~]# mysql -u root -p Enter password:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Caofeng2012@'; Query OK, 0 rows affected (0.00 sec)
設定允許遠端登入Mysql預設不允許遠端登錄,我們需要設定下,並且防火牆開放3306埠;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Caofeng2012@' WITH GRANT OPTION; Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> exit; Bye
#
[root@localhost ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent success [root@localhost ~]# firewall-cmd --reload success [root@localhost ~]#
配置預設編碼為utf8修改/etc/my.cnf配置文件,在[mysqld]下添加編碼配置,如下所示:
[mysqld] character_set_server=utf8 init_connect='SET NAMES utf8' [root@localhost ~]# vi /etc/my.cnf
編輯已儲存完重啟mysql服務;
[root@localhost ~]# systemctl restart mysqld [root@localhost ~]#
mysql> show variables like '%character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
rrreee
第九步:測試
我們用本機的sqlyog遠端連線下虛擬機器裡的mysql######## #########OK 至此Mysql安裝配置完畢;###以上是mysql5.7在Centos7.3下安裝配置的圖文教程的詳細內容。更多資訊請關注PHP中文網其他相關文章!