Problems encountered during the use of mysql

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.
Insert image description here
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

Insert image description here

  • 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

Insert image description here

  • 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. . .

Guess you like

Origin blog.csdn.net/xdg15294969271/article/details/125396872