I had previously successfully installed mysql-server
on Ubuntu 16.04 but as I didn't remember root password and had no db created, I tried to reinstall it. I tried many times but it seems that the process does not complete as it does not ask for root password and does not create the mysql directories in /etc
and /var/lib
. As a result, the server doesn't start.
This is how I remove mysql-server:
sudo apt-get remove --purge mysql-server
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql* /etc/mysql*
deluser mysql
delgroup mysql
Reinstallation log :
$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
mysql-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/10.8 kB of archives.
After this operation, 164 kB of additional disk space will be used.
Selecting previously unselected package mysql-server.
(Reading database ... 207500 files and directories currently installed.)
Preparing to unpack .../mysql-server_5.7.13-0ubuntu0.16.04.2_all.deb ...
Unpacking mysql-server (5.7.13-0ubuntu0.16.04.2) ...
Setting up mysql-server (5.7.13-0ubuntu0.16.04.2) ...
$
$ ls /etc/my*
ls: cannot access '/etc/my*': No such file or directory
$ ls /var/lib/my*
ls: cannot access '/var/lib/my*': No such file or directory
$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
$ sudo /etc/init.d/mysql start
[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
failed!
$