Knowing that MySQL is 5.7, and the online performance has increased one or two times times, so installed on the virtual machine CentOS 7, installed on top of MySQL 5.7
I am using the Yum installation method, which requires the virtual machine to be able to surf the internet because it will download the installation package online
Installation with Yum is simple, with the ability to access the Internet, to perform
Yum List |grep MySQL
Find an installable MySQL package, I want to install 5.7 client and server, basically execute
Yum Install Mysql-community-client
Yum Install Mysql-community-server
You can do it.
This article focuses on the reset method of the root initial password
mysql5.7 was installed successfully, but the logon method described in the previous version was unsuccessful:
1) The default root password is empty, in fact, is not empty, using Mysql-u root-p Login failed
2) using Mysqladmin to reset the password is unsuccessful, because it requires an initial password, but I did not know the initial password to reset, failed
3) Use Mysqld_safe to reset, this is even more unreliable, in the root directory execution Find-name Mysqld_safe, cannot find this file
4) said in the/root/directory there is a. Mysql_secret Initialize the password file, this also line, this file does not exist at all, after manual creation, use Mysqladmin boot also do not recognize this password
In fact, to reset the 5.7 password is very simple, a layer of window paper:
1, modify the/ETC/MY.CNF, add a line under the [mysqld] subsection: Skip-grant-tables=1
This line of configuration allows mysqld to be not validated at startup
2. Restart MYSQLD service: systemctl restart Mysqld
3. Log in to Mysql:mysql-u root using the root user
4. Switch to MySQL database and update user table:
Update user Set authentication_string = password (' root '), password_expired = ' N ', password_last_changed = Now () where user = ' root ';
In previous versions, the field name for the password field was password,5.7 to authentication_string
5. Quit MySQL, edit the/etc/my.cnf file, delete the contents of Skip-grant-tables=1
6, restart the Mysqld service, and then login with the new password can
In addition, MySQL 5.7 generates a random initial password after initial installation (CentOS7 OS) and is recorded in the/var/log/mysqld.log, which can be viewed through the cat command, looking for the password keyword
After locating the password, log in with the initial password, and (only) change the root user's password to root by alter user ' root ' @ ' localhost ' identified by ' root ', then exit, Log in again with the root user and the password you just set.
-
Top
-
0
mysql5.7.11 changing the root default password