You can find out this kind of problem just by Baidu. But since I have answered it, I will explain it to you in detail. 1. Check whether the database password is set; 2. Have the password been changed since the database was started? If the password has been changed, flush privileges; 3. How many MySQLs have been installed? Log in with the absolute path: /path/to/mysql/bin/mysql -u username -p and press Enter. If you set a password, enter the password and press Enter. If you do not set a password, just press Enter to log in.
mysql -u root
Just press enter without password
Enter the password (I encountered this before and didn’t study it carefully, but entering the password seems to solve the problem
You can find out this kind of problem just by Baidu.
But since I have answered it, I will explain it to you in detail.
1. Check whether the database password is set;
2. Have the password been changed since the database was started? If the password has been changed, flush privileges;
3. How many MySQLs have been installed? Log in with the absolute path: /path/to/mysql/bin/mysql -u username -p and press Enter. If you set a password, enter the password and press Enter. If you do not set a password, just press Enter to log in.