I haven't written a blog for a while, and I have forgotten a lot of things on paper and on my computer. Some of them may be missing, but I still need to develop a good habit of timely sorting and recording. One day I used an idle old server, but I forgot my mysql password. So I checked it online and recorded it as follows:
- Stop mysql service:
#:/Etc/init. d/mysql stop
- Ignore permission check to start mysql
#: Mysqld -- skip-grant-tables &
- Login without a password:
$: Mysql-u root
- Change Password:
> Use mysql;
> Update user set Password = PASSWORD ('newpasswd') where User = 'root ';
- Refresh and exit:
> Flush privileges;
> Quit
- Restart mysql:
#:/Etc/init. d/mysql start
If the database is empty or data is no longer needed, you can delete the database file and restart the database. The database will be reinitialized.
Database File Location:/var/lib/mysql