Operating system is CENTOS7 64
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.
Set Allow Telnet
MySQL default does not allow Telnet, we need to set up, and firewall open 3306 port;
Mysql>CREATE USER ' tom ' @ ' localhost ' identified by ' 123.com ';Create user
[Email protected] ~]# firewall-cmd--zone=public--add-port=3306/tcp--permanent
Success
[Email protected] ~]# Firewall-cmd--reload
Success
[Email protected] ~]#
Open 3306 Ports
After MySQL installation, turn on remote