Ubuntu
在 Ubuntu 20.04 Bash for Windows 上安裝 mysql-server 時出錯
請原諒任何錯誤;這是我第一次在 Stack Exchange 上發帖。
MySQL 在 Ubuntu Bash for Windows 上安裝時會拋出錯誤並且無法安裝。我在 Stack Exchange 和其他網站上查看了幾個答案,但他們的建議並不能解決我的問題。
我已經執行 sudo apt clean、清除 MySQL、更新和升級、執行 dkpg –configure -a 和 sudo apt install -f。它仍然拋出這個錯誤:
Setting up mysql-server-8.0 (8.0.25-0ubuntu0.20.04.1) ... invoke-rc.d: could not determine current runlevel * Stopping MySQL database server mysqld [ OK ] Renaming removed key_buffer and myisam-recover options (if present) Cannot open /proc/net/unix: No such file or directory Cannot stat file /proc/1/fd/5: Operation not permitted Cannot stat file /proc/1/fd/10: Operation not permitted Cannot stat file /proc/1/fd/6: Operation not permitted Cannot stat file /proc/6/fd/7: Operation not permitted Cannot stat file /proc/6/fd/10: Operation not permitted Cannot stat file /proc/6/fd/5: Operation not permitted mysqld will log errors to /var/log/mysql/error.log mysqld is running as pid 4376 dpkg: error processing package mysql-server-8.0 (--configure): installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1 No apport report written because the error message indicates its a followup error from a previous failure. dpkg: dependency problems prevent configuration of mysql-server: mysql-server depends on mysql-server-8.0; however: Package mysql-server-8.0 is not configured yet. dpkg: error processing package mysql-server (--configure): dependency problems - leaving unconfigured Processing triggers for man-db (2.9.1-1) ... Processing triggers for sgml-base (1.29.1) ... Processing triggers for libc-bin (2.31-0ubuntu9.2) ... Errors were encountered while processing: mysql-server-8.0 mysql-server E: Sub-process /usr/bin/dpkg returned an error code (1)
/var/log/mysql/error.log 顯示:
2021-07-01T16:03:10.840389Z 0 [ERROR] [MY-010262] [Server] Can't start server: Bind on TCP/IP port: Address already in use 2021-07-01T16:03:10.840489Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3306 ? 2021-07-01T16:03:10.840710Z 0 [ERROR] [MY-010119] [Server] Aborting
我無法停止 mysqld 服務。Ubuntu 說當我嘗試時它沒有被辨識為服務。
按照此處的說明進行操作:https ://stackoverflow.com/questions/62127891/cant-install-mysql-on-pure-ubuntu-20-04
sudo apt-get purge mysql* sudo apt-get autoremove sudo apt-get autoclean sudo apt-get remove dbconfig-mysql sudo apt-get dist-upgrade //This successfully removed it and I was able to install: sudo apt update sudo apt install mysql-server sudo mysql_secure_installation
但是,它不會啟動,給出一個
Can't connect to local MySQL server through socket
錯誤。同樣的問題有一個解決方案:" 在 ubuntu 上,我做了以下事情:
sudo mysqld_safe --skip-grant-tables --skip-syslog --skip-networking
然後在新終端中執行 mysql:
mysql -u root
並執行以下查詢來更改密碼:FLUSH PRIVILEGES;
在 MySQL 5.7 中,mysql.user 表欄位中的密碼欄位被刪除,現在欄位名稱為 ‘authentication_string’。
引用了答案後,請注意 PASSWORD() 函式已被棄用,因為在此答案中共享。如那裡所述,只需使用我使用 MD5() 的任何 MySQL 加密函式替換它。
最後:
* Starting MySQL database server mysqld [ OK ]
“在安全模式下執行它之前,我確實必須創建 /var/run/mysqld 目錄,使用這些說明並在所有命令前加上
sudo
.