I'm usually not using Ubuntu, but decided to give it a try today because it's the preferred distro for Windows Subsystem for Linux, that I wanted to try today to see if/how it could replace my VMWare machines on Windows 10.

So I'm using Ubuntu on WSL, although I don't think it makes a difference here.

Anyway, I installed the MySQL APT repo to get MySQL 8.0:

$ wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
$ sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb
$ sudo apt-get update
$ sudo apt-get install mysql-server

Now when I attempt to start the mysql service, I have no luck:

$ sudo service mysql start
mysql: unrecognized service

$ sudo service mysqld start
mysqld: unrecognized service

$ sudo service mysql-server start
mysql-server: unrecognized service

A quick look at init.d shows that there is no file for mysql:

$ ls -al /etc/init.d/mysql*
ls: cannot access '/etc/init.d/mysql*': No such file or directory

Note that I cannot use systemctl to start a service, as systemd is not available on WSL.

Now the interesting part: when I list the files inside the mysql-server package, it only contains files in /usr/share!

$ dpkg-query -L mysql-server

Why is the mysql-server package missing the actual server files in MySQL APT repo?

  • 1
    Try the command apt depends mysql-server to list the packages that mysql-server depends upon. The server files are in those packages. msql-server is a version-independent package with an easy-to-remember name that pulls in the appropriate version of the actual server package(s).
    – user535733
    Jul 24 '19 at 12:52
  • Thank you, I can see that mysql-server depends on mysql-community-server, which in turn depends on mysql-community-server-core. The second one contains the service files, i.e. /lib/systemd/system/mysql.service, while the third one contains the actual mysqld binary. So it looks like these packages cannot work without systemd, can they?
    – BenMorel
    Jul 24 '19 at 14:50
  • Mysql should work without the .service file. I suspect that's a red herring: The service file merely tells systemd the correct path-and-binary to launch...but you already know that. Note that your original problem was that you were trying to use sysvinit (instead of systemd) to start mysql-server. Among the same files, you should discover the sysvinit init file -- copy it into /etc/init.d/
    – user535733
    Jul 24 '19 at 14:55
  • The problem is, I don't want to manually start mysqld, I want to get it to start on boot. I can't see a sysvinit file in the package contents, what/where should I be looking for?
    – BenMorel
    Jul 24 '19 at 15:18
  • see if the comment here helps -- github.com/Microsoft/WSL/issues/3631#issuecomment-465966498
    – e-cloud
    Aug 29 '19 at 13:38

Expanding on the answer of e-cloud, the issue is apparently that the installation of MySQL 8.0 does not create the files, that allow the service command to find the installation. These files are created when installing MySQL 5.7 though and will remain when upgrading to 8.0 afterwards.


  • The exported envvar REPO in the script below sets the name of the mysql-apt-config file. You can find the most recent version at https://dev.mysql.com/downloads/repo/apt/
  • The script was tested on a fresh installation of debian in a WSL2 environment and installs some dependencies first. If you had already installed MySQL 8.0, you can comment the first block and uncomment the second block to clean up your previous installation instead
  • I didn't like the approach of rewriting the service init script to point to the 8.0 installation, so this removes the 5.7 folder instead and symlinks that path to the 8.0 folder
# mysql config to use
export REPO=mysql-apt-config_0.8.18-1_all.deb

# update system and install dependencies (fresh wsl debian image)
sudo apt update
sudo apt -y upgrade
sudo apt -y install lsb-release wget gnupg
wget –c https://dev.mysql.com/get/${REPO}

# or remove a previous installation
#sudo apt -y remove mysql-server mysql-client
#sudo apt -y autoremove && sudo apt -y autoclean

# install mysql server 5.7 to get the service init.d files
sudo dpkg -i ${REPO} # select 5.7
sudo apt update
sudo apt -y install mysql-server

# switch to mysql server 8.0 and update, link mysql path to new location
sudo dpkg -i ${REPO} # select 8.0
sudo apt update
sudo apt -y install mysql-server mysql-client
sudo rm -rf /usr/share/mysql
sudo ln -s mysql-8.0 /usr/share/mysql

# run the service
sudo service mysql start

see if the comment here helps -- https://github.com/Microsoft/WSL/issues/3631#issuecomment-465966498

here is my workable gist https://gist.github.com/e-cloud/34acbefe0597a02f9a081a01eff6dd24

sudo apt-get remove mysql-server mysql-client -y
sudo apt-get autoremove -y && sudo apt-get autoclean -y

wget –c https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb # select 5.7

sudo apt-get update
sudo apt policy mysql-server #(it will show 5.x is the default candidate)

sudo apt-get -y install mysql-server
# ensure your host windows have no mysql service running
sudo service mysql start
sudo service mysql stop

sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb # select 8.0
sudo apt-get update
sudo apt policy mysql-server #(it will show 8.x is the default candidate)

sudo apt-get -y install mysql-server
sudo sed -ie 's/\/usr\/share\/mysql\/mysql-helpers/\/usr\/share\/mysql-8.0\/mysql-helpers/' /etc/init.d/mysql
sudo service mysql start
  • 1
    Your gist doesn't explain why this does it, and because comments and links can die at any time the part about "see the comment here to see if it helps" is a link-only answer portion. That part is frowned upon because of the nature of this site. (Please also don't repost your post if it's already been deleted, it just adds noise and doesn't help much, especially since 'random gist solution' without explanation isn't very useful.
    – Thomas Ward
    Aug 29 '19 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.