1. 程式人生 > 其它 >linux mysql的安裝

linux mysql的安裝

沒有wget,先安裝wget

yum -y install wget
下載和安裝mysql源
wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum localinstall -y mysql57-community-release-el7-7.noarch.rpm
線上安裝mysql-community-server
yum install -y mysql-community-server
啟動mysql
systemctl start mysqld
設定開機啟動
systemctl enable mysqld
systemctl daemon-reload
檢視密碼
cat /var/log/mysqld.log | grep password

進入資料庫登陸介面,輸入剛剛查到的密碼,進行資料庫的登陸,複製貼上就行

mysql -uroot -p 
mysql> use mysql
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

以上錯誤表示密碼需要重置

mysql> alter user 'root'@'localhost' identified by '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

以上錯誤與validate_password_policy的值有關,接著修改這個值

mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)

完成之後再修改密碼就OK了

mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)