Centos7.4使用yum安裝Mysql5.7.19的詳細步驟

Centos7的yum源中默認是沒有mysql,因爲現在已經用mariaDB代替mysql了。

首先我們下載mysql的repo源,我們可以去mysql官網找最新的repo源地址

地址:

https://dev.mysql.com/downloads/repo/yum/

開始在linux下下載repo源

//下載mysql rpm包
# wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

//安裝mysql rpm包
# rpm -ivh mysql57-community-release-el7-11.noarch.rpm

//安裝mysql
# yum install mysql-community-server

安裝成功後需要重啓mysql服務。

# service mysqld restart

剛開始安裝的Mysql5.7是會隨機生成一個root密碼的,我們要先找到這個隨機密碼,然後改新密碼。如果找不到密碼的再執行一次

service mysqld restart
我們可以通過grep命令查找隨機root密碼。
[root@local bin]# grep "password" /var/log/mysqld.log
2017-09-24T08:03:30.664086Z 1 [Note] A temporary password is generated for root@localhost: 8A3xwbk8_P1A

使用隨機密碼登錄mysql

[root@local bin]# mysql -uroot -p
Enter password: 

進入後重置root密碼

mysql> SET password=PASSWORD("mysql123");
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

如果有上面的報錯,說明密碼設置的過於簡單。密碼設置規則是要有數字大小寫字母和字符串。

最後授予外網登錄權限,username爲用戶名,password是登錄密碼

mysql>grant all privileges on *.* to username@'%' identified by 'password';



grant all on *.* to test@'%' identified by 'Test123456.';

這個可以直接設置用戶名test和密碼,並且設置了能夠遠程訪問


如果不需要密碼的話,直接進入mysql後設置對應的用戶名authentication_string這個字段爲null。特別是root本地的,應該是不需要密碼的

設置mysql的默認新建數據庫的編碼:

my.ini,裏面[mysqld]增加了character_set_server=utf8

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章