Ubuntu – Why is the thesql-server package from thesql.com missing server files

MySQLwindows-subsystem-for-linux

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
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/mysql-server
/usr/share/doc/mysql-server/LICENSE.gz
/usr/share/doc/mysql-server/README
/usr/share/doc/mysql-server/changelog.Debian.gz
/usr/share/doc/mysql-server/copyright
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/mysql-server

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

Best Answer

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.

Notes:

  • 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