Reset the root password for MySQL under Ubuntu
sudo vi/etc/mysql/my.cnf, adding a line "skip-grant-tables" to the [Mysqld] Segment
sudo service mysql restart, restart MySQL services
sudo mysql-u root-p mysql, enter MySQL admin command line with a blank password
(go to MySQL, or use the MySQL command)
Update user set Password=password ("123″) where user= ' root ';, reset the password to 123
(Note that if the user name is not in the table, insert is used)
Quit, exit database management
sudo vim/etc/mysql/my.cnf, comment or delete the line that you just joined "Skip-grant-tables"
sudo service MySQL restart,ok, fix it!
Attention:
In the latest version of MySQL, I was supposed to be MySQL 5.7, he did not have the password field in the database user, with authentication_string
This field is proxy, so the SQL statement should be changed to a more
Update user set Authentication_string=password ("123″) where user= ' root ';
It's OK to do the processing again.
Suggestions:
When MySQL opens a remote connection, the root user is generally not exposed, it is recommended to create a new user, and then expose the newly established users to connect.
MySQL Reset password