mysql-5.7安裝部署+MySQL5.7初始密碼查看及重置


                          mysql-5.7安裝部署+MySQL5.7初始密碼查看及重置

 

系統環境 Centos 7.6

 

首先下載mysql安裝包:

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar

解壓:

tar -xvf mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar

 

開始安裝:

yum -y remove  mariadb*

yum -y install mysql-community-common-5.7.27-1.el7.x86_64.rpm

yum -y install mysql-community-libs-5.7.27-1.el7.x86_64.rpm

yum -y install mysql-community-libs-compat-5.7.27-1.el7.x86_64.rpm

yum -y install mysql-community-devel-5.7.27-1.el7.x86_64.rpm

yum -y install mysql-community-client-5.7.27-1.el7.x86_64.rpm
yum -y install mysql-community-server-5.7.27-1.el7.x86_64.rpm
yum -y install mysql-community-libs-compat-5.7.27-1.el7.x86_64.rpm

啟動mysql

systemctl  restart mysqld

mysql加入開機自動

systemctl  enable mysqld

 

MySQL5.7初始密碼查看及重置

安裝了mysql5.7之后初始密碼不再默認為空

1.查看初始密碼:

[root@VM_225_102_centos ~]# grep 'temporary password' /var/log/mysqld.log 
2016-07-08T02:25:46.311098Z 1 [Note] A temporary password is generated for root@localhost: MtPqF0/oN5zo

即初始密碼為 MtPqF0/oN5zo    (密碼是隨機產生的,每台機器產生的都不一樣哦)

或者

另外一種方法查看默認密碼:

[root@localhost src]# cat /root/.mysql_secret

# The random password set for the root userat Fri Jan 10 20:00:34 2014 (local time): aJqZsA2m

這里的aJqZsA2m就是生成的root隨機密碼啦

2.登錄及修改密碼:

[root@VM_225_102_centos ~]# mysql -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.11


Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

 

登錄之后 第一步必須先修改密碼,否則其他操作都執行不了。

 

修改密碼的方法:

 

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

新修改的密碼中 必須包含 大小寫字母數字及符號

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM