1. Problem description
I was still using mysql this morning, but when I tried it again in the afternoon, it said that my password was wrong and I couldn't log in.
But I have never touched other configurations?
2. Solution
Here I reinstalled mysql. If you don't have important data, you can do this. If there is important data, try to back up the data first.
- First delete all mysql dependent libraries
sudo pacman -R mysql libmysqlclient mysql-clients
- Then delete the mysql configuration file (enter the super user interface first)
cd /var/lib/mysql
rm -rf *
- Install mysql
sudo pacman -S mysql
- Initialize mysql (this step obtains the mysql initial password)
sudo mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql
- Restart mysql (note, be sure to restart mysql first)
sudo systemctl restart mysqld
- Log in to mysql (use the initial password just now)
mysql -u root -p
- Change password
After entering mysql, reset the password.
I'm really grateful, because I didn't have to restart that step, I did it dozens of times. . .