WSL: Error 2002 (HY000): Unable to connect to local MySQL server via socket '/var/run/mysqld/mysqld.sock' (13)
P粉073857911
P粉073857911 2023-12-25 14:49:48
0
1
536

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

P粉073857911
P粉073857911

reply all(1)
P粉680087550

I recently installed MySQL in WSL2.

First, I installed mysql-server using apt.

What I did next

Finally, I can run MySQL

Obviously, when you use sudo, mysql will run as root, so sudo is required to run it.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template