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
How to Create a New Page in Prestashop Admin Panel
Merge a Table and a Change Log into a View in Postgresql
Pass a Variable to an Assetic Asset Url in Symfony2
Php: Check If Xml Node Exists with Attribute
PHP Making a Download Counter Without Leaving the Current Page
Woocommerce: Display Also Product Variation Description on Cart Items
Understanding PHP "Out of Memory" Error
Php: 'Or' Statement on Instruction Fail: How to Throw a New Exception
How to Get the First Day of the Week for the Current Locale? (Php/L8N)
Converting Dates with PHP for Datetime in SQL
Extension PHP5 Does Not Parse in Xampp
Multiple Routes in Single Route::Get() Call Laravel 4
How to Use Bind_Param for Order By
Get a Single Row from the Database Using Ajax in Codeigniter
Laravel 5.3 - HTMLspecialchars() Expects Parameter 1 to Be String