search

Home  >  Q&A  >  body text

WSL: Error 2002 (HY000): Unable to connect to local MySQL server via socket '/var/run/mysqld/mysqld.sock' (13)

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粉073857911P粉073857911393 days ago579

reply all(1)I'll reply

  • P粉680087550

    P粉6800875502023-12-26 10:37:05

    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.

    reply
    0
  • Cancelreply