在 Ubuntu 20.04 Bash for Windows 上安装 mysql-server 时出错

在 Ubuntu 20.04 Bash for Windows 上安装 mysql-server 时出错

如有错误,敬请谅解;这是我第一次在 Stack Exchange 上发帖。

MySQL 在 Windows 版 Ubuntu Bash 上安装时会抛出错误并且无法安装。我已经在 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 说它未被识别为服务。

Ubuntu 18.04 LTS:安装 MySQL 8.0 服务器的依赖项出现问题也没用。

答案1

按照此处的说明进行操作: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() 函数已被弃用,如在此答案中共享的那样。正如那里所述,只需使用我使用的任何 MySQL 加密函数 MD5() 替换它即可。

最后:

* Starting MySQL database server mysqld                     [ OK ]

“在安全模式下运行之前,我必须创建 /var/run/mysqld 目录,使用这些指令并为所有命令添加前缀sudo.

相关内容