MySQL Ubuntu 16.04 not starting
13,136
Solution 1
I had to remove mysql and reinstall it, now it works
Solution 2
In my case mysql
service not started because of this error.
A mysqld process already exists
(found it from /var/log/mysql/error.log
).
So, I was needed to kill the process and start again:
sudo killall mysqld mysqld_safe
ps aux | grep mysqld
sudo killall -9 mysqld mysqld_safe # use this if some mysqld process remained
And this helped for me.
Related videos on Youtube
Author by
Ilqar Rasulov
Updated on September 18, 2022Comments
-
Ilqar Rasulov over 1 year
I have tried to open Mysql in Linux Ubuntu 16.04 but I got an error:
ilqar@ubuntu:~$ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Then I tried to start the mysql server:
ilqar@ubuntu:~$ sudo service mysql start Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details. ilqar@ubuntu:~$ ^C ilqar@ubuntu:~$ systemctl status mysql.service ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: inactive (dead) (Result: exit-code) since Sun 2018-01-21 10:39:04 +04; 17s ago Process: 3620 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE) Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Control process exited, code=exited status=1 Jan 21 10:39:04 ubuntu systemd[1]: Failed to start MySQL Community Server. Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Unit entered failed state. Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Failed with result 'exit-code'. Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Service hold-off time over, scheduling restart. Jan 21 10:39:04 ubuntu systemd[1]: Stopped MySQL Community Server. Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Start request repeated too quickly. Jan 21 10:39:04 ubuntu systemd[1]: Failed to start MySQL Community Server. ilqar@ubuntu:~$ journalctl -xe -- -- Unit mysql.service has finished shutting down. Jan 21 10:39:04 ubuntu systemd[1]: Starting MySQL Community Server... -- Subject: Unit mysql.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mysql.service has begun starting up. Jan 21 10:39:04 ubuntu mysql-systemd-start[3611]: MySQL system database not found in /var/lib/mysql. Please run mysqld --initialize. Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Control process exited, code=exited status=1 Jan 21 10:39:04 ubuntu systemd[1]: Failed to start MySQL Community Server. -- Subject: Unit mysql.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mysql.service has failed. -- -- The result is failed. Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Unit entered failed state. Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Failed with result 'exit-code'. Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Service hold-off time over, scheduling restart. Jan 21 10:39:04 ubuntu systemd[1]: Stopped MySQL Community Server. -- Subject: Unit mysql.service has finished shutting down -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mysql.service has finished shutting down. Jan 21 10:39:04 ubuntu systemd[1]: Starting MySQL Community Server... -- Subject: Unit mysql.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mysql.service has begun starting up. Jan 21 10:39:04 ubuntu mysql-systemd-start[3620]: MySQL system database not found in /var/lib/mysql. Please run mysqld --initialize. Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Control process exited, code=exited status=1 Jan 21 10:39:04 ubuntu systemd[1]: Failed to start MySQL Community Server. -- Subject: Unit mysql.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mysql.service has failed. -- -- The result is failed. Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Unit entered failed state. Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Failed with result 'exit-code'. Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Service hold-off time over, scheduling restart. Jan 21 10:39:04 ubuntu systemd[1]: Stopped MySQL Community Server. -- Subject: Unit mysql.service has finished shutting down -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mysql.service has finished shutting down. Jan 21 10:39:04 ubuntu systemd[1]: mysql.service: Start request repeated too quickly. Jan 21 10:39:04 ubuntu systemd[1]: Failed to start MySQL Community Server. -- Subject: Unit mysql.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mysql.service has failed. -- -- The result is failed.
I am newbie in Linux, please help me find out the problem.
-
Ilqar Rasulov over 6 yearshow did you find out the relevant error message? I did as you said and got another error <pre><code> ilqar@ubuntu:~$ sudo mysqld --initialize [sudo] password for ilqar: 2018-01-21T07:01:10.666769Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2018-01-21T07:01:10.694011Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting. 2018-01-21T07:01:10.694164Z 0 [ERROR] Aborting </code></pre>
-
Ilqar Rasulov over 6 yearshow did you find out the relevant message?
-
Chai T. Rex over 6 years@IlqarRasulov It's in your
journalctl -xe
output in the question. First-- Unit mysql.service has begun starting up.
then next line isJan 21 10:39:04 ubuntu mysql-systemd-start[3611]: MySQL system database not found in /var/lib/mysql. Please run mysqld --initialize.
-
Ilqar Rasulov over 6 yearsyes, sure. Just saw it.
-
Ilqar Rasulov over 6 yearsbut i couldn't initialize it cause the data directory is not empty, how can I solve it?
-
Ilqar Rasulov over 6 yearsI had to remove mysql and reinstall it, now it works
-
Chai T. Rex over 6 yearsExcellent :) Please add that as an answer below (including instructions on how to remove and reinstall MySQL) to help others and then click the checkmark next to it to mark the question as solved.
-
Joyner about 4 yearsOk. Thank you. Its edited by @Gryu.