Please excuse any mistakes; this is my first time posting on Stack Exchange.

MySQL throws errors when installing on Ubuntu Bash for Windows and does not install. I have looked at several answers on Stack Exchange and other sites, but what they suggest does not fix my problem.

I have run sudo apt clean, purged MySQL, updated and upgraded, run dkpg --configure -a, and sudo apt install -f. It still throws this error:

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:                                                                             
E: Sub-process /usr/bin/dpkg returned an error code (1) 

/var/log/mysql/error.log shows:

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] 

I cannot stop the mysqld service. Ubuntu says it is not recognized as a service when I try.

Ubuntu 18.04 LTS: Problem with dependencies installing MySQL 8.0 server did not work either.

  • Just fyi the service name is mysql (or mysql.service in full) - not mysqld Jul 1, 2021 at 16:35
  • Oh, okay. Thanks! That's not what the error output said, though, unless I'm misunderstanding what mysqld is. .
    – TarHalda
    Jul 1, 2021 at 16:58
  • I was just trying to shed some light on why you cannot stop it using the mysqld service name. For information on what service might be listening on port 3306 you can use lsof ex. sudo lsof -i :3306 Jul 1, 2021 at 17:08
  • @steeldriver Thanks! It is not returning anything though. I can start the mysql service, but then I get ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
    – TarHalda
    Jul 2, 2021 at 16:09
  • Yeah I tried it myself and it looks like it just doesn't work - although /usr/sbin/mysqld runs. I suspect this is a Microsoft/WSL issue rather than a Unix/Ubuntu one. Jul 2, 2021 at 16:38

1 Answer 1


Followed the instructions here: 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

However, then it wouldn't start, giving a Can't connect to local MySQL server through socket error. That same question had a solution to that:

" On ubuntu I did the following:

sudo mysqld_safe --skip-grant-tables --skip-syslog --skip-networking

Then run mysql in a new terminal:

mysql -u root And run the following queries to change the password:


In MySQL 5.7, the password field in mysql.user table field was removed, now the field name is 'authentication_string'.

Having quoted the answer, please note the PASSWORD() function has been deprecated as shared in this answer over here. As stated there, just replace it using any of the MySQL encryption functions I used MD5().


* Starting MySQL database server mysqld                     [ OK ]

" I did have to create the /var/run/mysqld directory before running it in safe mode, using these instructions and prefixing all commands with sudo.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .