When I configured XAMPP on a computer today, I created a new user in the above PHPMyAdmin and created a password, but I have been unable to use this account to log in to MySQL.
If you use PHPMyAdmin, you will be prompted to log in failed. If you log in directly from the command line, you will be prompted with ERROR 1045 (28000): Access denied for user 'laravel'@'localhost' (using password: YES)
. As shown below:
According to the solution mentioned on the Internet, I tried to use the root account, the laravel account, for authorization , directly authorize all privileges to it, but the login is still unsuccessful.
Finally, after many attempts, I finally discovered the problem: there is an account with an empty user name in MySQL by default. As long as you are local, you can log in to MySQL without entering the account password. Because of the existence of this account, logging in using a password cannot be used to log in correctly.
Solution:
Just log in through the root account, and then The account can be deleted:
mysql -u root # 以root账户登录MySQL use mysql #选择mysql库 delete from user where User=''; #删除账号为空的行 flush privileges; #刷新权限 exit #退出mysql
Now, you can log in using the account and password you just created:
[Related recommendations]
1. Free mysql online video tutorial
2. MySQL latest manual tutorial
3. Boolean Education Yan Shiba mysql introductory video tutorial
The above is the detailed content of How to solve the problem that new MySQL users cannot log in?. For more information, please follow other related articles on the PHP Chinese website!