I tried to install MySQL on WSL2 Ubuntu 20.04 using this steps: https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-database#install-mysql
But when I prompt sudo mysql_secure_installation
and ask for password, I get this error Error: Access denied for user 'root'@'localhost' (using password: NO)
After I did a google search, I found most of the solutions using this command mysql -u root -p
But I got another error ERROR 2002 (HY000): Can 't connect to local MySQL server through socket '/ var/run/mysqld/mysqld.sock' (13)
I have started the server using this command sudo /etc/init.d/mysql start
It says the server is starting but I still get error 2002. I tried another command sudo service mysql start
Still didn't work
I recently installed MySQL in WSL2.
First, I installed
mysql-server
usingapt
.What I did next
Finally, I can run MySQL
Obviously, when you use
sudo
,mysql
will run as root, sosudo
is required to run it.