Home > Database > Mysql Tutorial > How to solve the problem that new MySQL users cannot log in?

How to solve the problem that new MySQL users cannot log in?

零下一度
Release: 2017-05-05 16:38:30
Original
1965 people have browsed it

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:

How to solve the problem that new MySQL users cannot log in?

Using command line login error

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.

How to solve the problem that new MySQL users cannot log in?

You can log in to MySQL on this machine without any account or password

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
Copy after login

Now, you can log in using the account and password you just created:

How to solve the problem that new MySQL users cannot log in?

Login successful

[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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template