Hi @bellpep
Did you setup the mysql root password?
On a server you should have the script "mysql_secure_installation" that you can manually execute to do the job.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
So I've been having issues getting MySQL to work on WSL 2 for days now and I cannot figure it out. I've searched through tons and tons of stackoverflow/laracast forum posts but nothing has worked so far.
I posted about this once before and thought I found a solution here but when I get to step 4 and enter grant all privileges on *.* to root@localhost identified by 'YourNewPassword' with grant option; I get this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'password' with grant option' at line 1
I'm using
Here's my process:
I create a fresh Laravel project and start it up
curl -s https://laravel.build/example-app | bash
cd example-app
./vendor/bin/sail up
I install and start MySQL
sudo apt-get install mysql-server
sudo service mysql start
But when I try to connect to MySQL
sudo mysql -uroot -p
Enter password:
I get the following error:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Here's my .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=exampleapp
DB_USERNAME=root
DB_PASSWORD=password
I've also tried connecting to MySQL through phpMyAdmin but I get a Permission Denied error. I've been stuck on this for days and really have no idea what to do. If anyone has insight on this problem I'd appreciate it a lot. If there's any additional information I can provide please let me know and I'll respond with it ASAP.
Please or to participate in this conversation.