7

I followed the instruction here to install mariadb on WSL after following the steps. and I run this

sudo service mysql start

I got

mysql: unrecognized service

Any idea how to solve this?

1
  • 1
    Perhaps it should be mysqld, not mysql?
    – Rick James
    Jul 12, 2019 at 4:16

2 Answers 2

8

It's just a simple problem as you see but it takes me 24 hours to diagnose the problem.

Solution: I uninstall mariadb with this command

sudo apt-get remove --auto-remove mariadb-server

and install sudo apt install mysql-server instead but it leads to a more problems

Successfully install mysql but can't start

dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

so by removing mariadb's deb sources and purging mysql-common and then reinstalling it.

do: sudo apt edit-sources

and look for anything containing mariadb like: deb [arch=amd64,arm64,ppc64el] http://ftp.nluug.nl/db/mariadb/repo/10.3/ubuntu bionic main

comment it out by putting a # in front of it. then run

sudo apt update
sudo apt purge mysql-common
sudo apt install mysql-common

after that you can installed mysql-server properly via sudo apt install mysql-server, then do:

sudo apt purge mysql-server mysql-server-5.7
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-5.7 mysql-client-core-5.7


sudo rm -rfv /etc/mysql /var/lib/mysql

sudo apt autoremove

sudo apt autoclean

Finally:

sudo apt update    
sudo apt install mysql-server mysql-client --fix-broken --fix-missing

References: https://askubuntu.com/questions/980314/cannot-install-mysql-server-in-ubuntu16-0-4 https://askubuntu.com/questions/763534/cannot-reinstall-mysql-server-after-its-purge

1
  • 1
    Simply running the final steps resolved it for me "sudo apt update sudo apt install mysql-server mysql-client --fix-broken --fix-missing"
    – Mick P
    Jan 28, 2021 at 11:32
5

Which Linux distribution are you using on your WSL?

First, try the following:

systemctl {start|stop|restart|status} mysql

OR

service mysql {start|stop|restart|status}

to manage the MySQL service.

The reasons can be the following:

  1. Wrong service name:

    On some Linux distributions, the service is named as mysqld instead of mysql.

    To check: Run chkconfig --list on your WSL and identify the correct service name.

  2. File permission issues:

    Please ensure that the files in /var/lib/mysql have 770 permissions and ownership set to mysql user.

    To fix:

    chmod -R 770 /var/lib/mysql
    chgrp -R mysql /var/lib/mysql
    

    In addition to that, ensure that the /etc/rc.d/init.d/mysqld script has executable permissions to modify mysqld.

    To fix:

    chmod 755 /etc/rc.d/init.d/mysqld
    
  3. Missing/Corrupted MySQL server package:

    Reinstall MySQL!

6
  • Okay. Can you please check with the above solutions. Jul 11, 2019 at 10:56
  • 2
    chkconfig is unrecognized
    – Fil
    Jul 11, 2019 at 12:10
  • I think Ubuntu recently removed chkconfig. You can try sysv-rc-conf. sudo apt install sysv-rc-conf Then you can use sysv-rc-conf --list Jul 11, 2019 at 12:24
  • 2
    Unable to locate package sysv-rc-conf
    – Fil
    Jul 11, 2019 at 12:25
  • Can you try using the following: systemctl {start|stop|restart|status} mysql OR service mysql {start|stop|restart|status} Jul 11, 2019 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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