Recently the project has used MySQL, the project has no OPS, the project manager told me to use Linux under the basic environment, which encountered a variety of pits, now record, convenient for later.
The following content is from the online excerpt, if there is infringement, please contact me to delete.
1.mysql5.7 generates an initial password, and the previous version does not need to be logged on for the first login.
Shell> Find/-name. Mysql_secret
Shell> Vim/var/log/mysqld.log
/password find a temporary generated password
2. If the first step succeeds, use this password to continue with the 7th step
3. Modify the MySQL configuration file (default is/ETC/MY.CNF) and add a line under [Mysqld] Skip-grant-tables
A. Close the running MySQL service.
B. Vim/etc/my.ini last line Add skip-grant-tables//start MySQL service and Skip permission table authentication.
4.service mysqld Restart, you can enter it directly with MySQL
5. mysql> Update Mysql.user set Authentication_string=password (' 123456 ') where user= ' root ' and Host = ' localhost ';
It's best to check the fields in the user table about the password before using the statement. Depending on the version, there are some authentication_string, some password
mysql> flush Privileges;
Mysql> quit;
6. Restore the/etc/my.cnf file and restart Mysql:service mysql Restart, this time you can use Mysql-u root-p ' 123456 ' to enter the
7.mysql>set PASSWORD = PASSWORD (' newpasswd '); Set new password//newpasswd is the new password
PS: Error: 1130-host. Is the workaround for the MYSQL server when allowed to connect
It may be that your account is not allowed to log on remotely, only on localhost. This time, as long as the computer on the localhost,
After logging in to MySQL, change the "host" entry in the "User" table in the "MySQL" Database and rename "%" from "localhost"
Mysql-u root-p
Mysql>use MySQL;
Mysql>update User Set host = '% ' where user = ' root ' and host = ' localhost ';
Mysql>select host, user from user;
Mysql>flush privileges;
Shell>service mysqld Restart;
MySQL forgot password processing process