我嘗試使用此步驟在 WSL2 Ubuntu 20.04 上安裝 MySQL:https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-database#install-mysql
但是當(dāng)我提示sudo mysql_secure_installation
並要求輸入密碼時(shí),我收到此錯(cuò)誤錯(cuò)誤:用戶'root'@'localhost'訪問被拒絕(使用密碼:NO)
在我進(jìn)行谷歌搜尋後,我發(fā)現(xiàn)大多數(shù)解決方案都是使用此命令mysql -u root -p
但我收到另一個(gè)錯(cuò)誤ERROR 2002 (HY000): Can 't connect to local MySQL server through socket '/ var/run/mysqld/mysqld.sock' (13)
我已經(jīng)使用此命令啟動(dòng)了伺服器 sudo /etc/init.d/mysql start
它說伺服器正在啟動(dòng),但我仍然收到錯(cuò)誤 2002。我嘗試了另一個(gè)指令 sudo service mysql start
仍然沒有'工作吧
我最近在 WSL2 中安裝了 MySQL。
首先,我使用 apt
安裝了 mysql-server
。
接下來我做了
最後,我可以運(yùn)行 MySQL
顯然,當(dāng)您使用sudo
時(shí),mysql
將以root用戶身份運(yùn)行,因此需要sudo
來運(yùn)行它。