1. 程式人生 > >MySQL單機版安裝 - RPM

MySQL單機版安裝 - RPM

準備環境:

CentOS 7.5 64位

關閉防火牆

關閉selinux

幫助文件:快速安裝MySQL

安裝常用工具:

[[email protected] ~]# yum install -y vim tree wget

 

下載rpm:

[[email protected] ~]# wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

 

安裝yum源:

[[email protected] ~]# yum install -y mysql80-community-release-el7-1.noarch.rpm

 

安裝mysql:

[[email protected] ~]# yum install -y mysql-community-server

 

啟動mysql:

[[email protected] ~]# systemctl start mysqld.service

 

檢查mysql啟動狀態:

[[email protected] ~]# systemctl status mysqld.service

 

配置mysql開機自啟動:

[[email protected]

~]# systemctl enable mysqld.service

 

第一次登入,獲取mysql的root使用者初始化密碼:

[[email protected] ~]# grep 'temporary password' /var/log/mysqld.log

 

修改mysql的root使用者的密碼:

[[email protected] ~]# mysql -uroot -p

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

 

常見問題:

1、ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

需要使用ALTER USER修改密碼。


2、ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

密碼的複雜度不符合要求。

 

密碼策略:

MySQL's validate_password plugin is installed by default. This will require that passwords contain at least one upper case letter, one lower case letter, one digit, and one special character, and that the total password length is at least 8 characters.

yum安裝的預設密碼策略:至少包含一個大寫字元、一個小寫字元、一個數字、一個特殊字元,並且密碼總長度至少是8個字元。

新增使用者:

[[email protected] ~]# mysql -uroot -p

mysql> use mysql;

mysql> CREATE USER '使用者名稱'@'%' IDENTIFIED BY '密碼';

mysql> grant all on 資料庫名稱.* to 'salt'@'%';

mysql> exit;