0

I had a lot of troubles trying to install MySQL on rspbian stretch,

so I ended up by deleting everything that has the word sql on it, I installed mysql-server back

sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install mysql-server mysql-client

But now I'm having this error when I try to log as root

pi@raspberrypi:~ $ sudo mysql --user=root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket 
'/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

When I tried to start the server I had this error :

Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xe" for details. 

the errors in the log were:

    ● mariadb.service - MariaDB 10.1.38 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2019-05-27 13:42:56 CET; 19s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 4740 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
  Process: 4663 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 4657 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 4655 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
 Main PID: 4740 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"

mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.

and :

  mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentica
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-sess
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] 
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warnin
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR]
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, co
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed sta
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exi
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authenti
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (sy
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-u
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/ra
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (system bus name :1.49 [/usr/bin/pkttyagent --notify-fd 5 --fallback], objec
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-user:pi to gain TEMPORARY authorization for action org.freedesktop.systemd
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (system bus name :1.49, object path /org/freedesktop/PolicyKit1/Authentica
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (system bus name :1.49 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/Auth
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-user:pi to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.5
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (system bus name :1.49, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_FR.UTF-8) (disconn
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (system bus name :1.49 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_F
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-user:pi to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.50 [systemctl start mysql] (o
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (system bus name :1.49, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_FR.UTF-8) (disconnected from bus)
lines 1835-1857/1857 (END)
mai 27 13:42:22 raspberrypi kernel: Voltage normalised (0x00000000)
mai 27 13:42:50 raspberrypi polkitd(authority=local)[810]: Registered Authentication Agent for unix-process:4643:531066 (system bus name :1.49 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_FR.UTF-8)
mai 27 13:42:54 raspberrypi polkitd(authority=local)[810]: Operator of unix-session:c1 successfully authenticated as unix-user:pi to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-units for system-bus-name::1.50 [systemctl start mysql] (owned by unix-user:pi)
mai 27 13:42:54 raspberrypi systemd[1]: Starting MariaDB 10.1.38 database server...
-- Subject: L'unité (unit) mariadb.service a commencé à démarrer
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- L'unité (unit) mariadb.service a commencé à démarrer.
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Note] /usr/sbin/mysqld (mysqld 10.1.38-MariaDB-0+deb9u1) starting as process 4740 ...
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [Warning] Can't create test file /var/lib/mysql/raspberrypi.lower-test
mai 27 13:42:56 raspberrypi mysqld[4740]: [97B blob data]
mai 27 13:42:56 raspberrypi mysqld[4740]: 2019-05-27 13:42:56 1995611952 [ERROR] Aborting
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
mai 27 13:42:56 raspberrypi systemd[1]: Failed to start MariaDB 10.1.38 database server.
-- Subject: L'unité (unit) mariadb.service a échoué
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- L'unité (unit) mariadb.service a échoué, avec le résultat failed.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Unit entered failed state.
mai 27 13:42:56 raspberrypi systemd[1]: mariadb.service: Failed with result 'exit-code'.
mai 27 13:42:56 raspberrypi polkitd(authority=local)[810]: Unregistered Authentication Agent for unix-process:4643:531066 (system bus name :1.49, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale fr_FR.UTF-8) (disconnected from bus)
lines 1835-1857/1857 (END)

How can I solve this problem ? knowing that I have tried countless of solution but none has worked

Dai Sy
  • 1
  • 5
  • Ref [this](https://stackoverflow.com/questions/36528518/cant-connect-to-var-run-mysqld-mysqld-sock) if it can help – Vidhyut Pandya May 27 '19 at 11:54
  • Is the server running? Also - when you say `I have tried countless of solution` it always helps to list these (and the outcome) so people don't suggest things you've already tried. – ethrbunny May 27 '19 at 12:03
  • When I tried to start the server first a prompt appered so I entered my pi password then I got this error : Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details. – Dai Sy May 27 '19 at 12:09
  • ... and what error(s) were in the logs? (go ahead and update the original post with any / all errors) – ethrbunny May 27 '19 at 12:10
  • Looks like your edits got clipped on the right side. – ethrbunny May 27 '19 at 12:20
  • I tried my best to put it right – Dai Sy May 27 '19 at 12:49

1 Answers1

0

Making a guess at this fragment

ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/r

possibly the mysql user doesn't have permission to update / create whatever folder it's pointing to at /var/<something>.

ethrbunny
  • 9,957
  • 8
  • 62
  • 117
  • Make sure the mysql user can access the location of the pid file and create what it needs. Same for /var/lib/mysql/* – ethrbunny May 27 '19 at 15:19