How to Resolve the Error: SQL Authentication Method Unknown in Laravel-Mysql

PHP + MYSQL + Laravel - SQLSTATE[HY000] [2002] Connection refused

thats mean your data in env not correct ,
try to change host from 127.0.0.1 to be mysql.
its works with me
like this :-

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=8880
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=password

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select database and table = BASE_TABLE ))

In the new my-sql if the password is left empty while installing then it is based on the auth_socket plugin.

The correct way is to login to my-sql with sudo privilege.

$ sudo mysql -u root -p

if you are using the MAMP in macOS then the version of MAMP you're using installs itself in /Applications/MAMP. First make sure via the MAMP console that the Mysql server is on. Then connect like this from command line:

/Applications/MAMP/Library/bin/mysql -uUsername -pPassword

Enter your database password and then updating the password using:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';

where new-password is your new database password or what you want

then type the following the command in my-sql terminal:

mysql> FLUSH PRIVILEGES;

By trying this i hoped your issue will be solved if not then do comments
Thank you

laravel php artisan migrate

Your php mysql extension doesn't support the version of MySQL server you are running.

I'm assuming you're running MySQL 8.0, which is new at the time of this post.

You need to update or rebuild PHP with support for the latest version of MySQL, or downgrade your MySQL Server version.

Another solution is to create a user with the mysql_native_password option.

CREATE USER 'user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' WITH GRANT OPTION;


Related Topics



Leave a reply



Submit