简体   繁体   中英

ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database (MySQL - MariaDB)

I'm currently making a simple app using Laravel and Xampp. While trying to connect the database and make migrations I got this error message from php artisan:

PHP error

php错误

So I decided to configure the database manually from the MySQL MariaDB shell (having started the session as the root user), but regardless of what user I try to gran privileges to on any database I get the following error:

MariaDB error

MariaDB 错误

The only possible reason I can come up with is the fact that there seems to be two different root user listed, but I don't thisnk this is the root of the problem, since I'm starting the shell as root, and not choosing one of these after starting.

User List

用户列表

I've already triple-checked my root user password (I've been starting the shell with this command mysql -u root -p -h 127.0.0.1). Trying to do this through the PHP MyAdmin interface yields the same error.

I'd appreciate any insights, thank you!

The multiple entries for 'root' are specifying which host addresses are allowed connections from (127.0.0.1 and % respectively)

Your error appears to be because your configured database connection (in Laravel) is using the user 'usario'. Search your files for where usario is defined and input the proper credentials to connect to your database in its place.

This is a common error when credentias supplied to MySQL/MariaDB are simply invalid. Bad username, bad password, or both. In this instance it looks as though you're trying to run a migration with a user that doesn't exist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM