web-dev-qa-db-fra.com

MySQL Ubuntu 16.04 ne démarre pas

J'ai essayé d'ouvrir Mysql dans Linux Ubuntu 16.04 mais j'ai une erreur:

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)

Ensuite, j'ai essayé de démarrer le serveur mysql:

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.

Je suis un débutant sous Linux, aidez-moi à trouver le problème.

2
Ilqar Rasulov

Je devais enlever mysql et le réinstaller, maintenant ça marche

2
Ilqar Rasulov

Le message d'erreur pertinent est

MySQL system database not found in /var/lib/mysql. Please run mysqld --initialize.

Essayez de courir

Sudo mysqld --initialize

puis essayez de redémarrer le service.

0
Chai T. Rex

Le problème est résolu lorsque vous supprimez mysql puis le réinstallez.

Pour supprimer complètement mysql, exécutez la commande suivante:

$ Sudo apt-get remove --purge --auto-remove mysql-client-* mysql-common mysql-server-*
$ Sudo rm -r /etc/mysql* /var/lib/mysql* /var/log/mysql*

Pour l'installer à nouveau, lancez:

$ Sudo apt-get install mysql-server
0
user760819