Question
Connecting to MySQL without pw - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I have a Wordpress website that used to work fine, but recently I received the message “Error establishing a database connection” when trying to navigate to it. Upon researching online, I realized it may be related to changing my db password.
So I am following instructions on resetting the Mysql pw from here - https://www.digitalocean.com/community/tutorials/how-to-reset-your-mysql-or-mariadb-root-password.
Steps:
sudo systemctl stop mysql
sudo mysqld_safe --skip-grant-tables --skip-networking &
Output:
2019-08-25T15:23:22.702830Z mysqld_safe Logging to syslog.
2019-08-25T15:23:22.707805Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2019-08-25T15:23:22.712056Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
I then do:
mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld
and then run
sudo mysqld_safe --skip-grant-tables --skip-networking &
Output
2019-08-25T15:33:49.404761Z mysqld_safe Logging to syslog.
2019-08-25T15:33:49.411891Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2019-08-25T15:33:49.443922Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2019-08-25T15:33:49.992471Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
From here, I do mysql -u root
, and see this
Output:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Troubleshooting done so far
To troubleshoot, I followed the suggestions from this post to find the sock file. I tried to do by by
sudo find / -type s
to find the mysql.sock
file, but do not find it in the list.
Output:
/run/acpid.socket
/run/dbus/system_bus_socket
/run/snapd-snap.socket
/run/snapd.socket
/run/uuidd/request
/run/user/0/systemd/private
/run/user/0/systemd/notify
/run/fail2ban/fail2ban.sock
/run/lvm/lvmpolld.socket
/run/lvm/lvmetad.socket
/run/systemd/journal/dev-log
/run/systemd/journal/socket
/run/systemd/journal/stdout
/run/systemd/journal/syslog
/run/systemd/private
/run/systemd/notify
/run/udev/control
/var/lib/lxd/unix.socket
/var/spool/postfix/private/proxywrite
/var/spool/postfix/private/relay
/var/spool/postfix/private/ifmail
/var/spool/postfix/private/retry
/var/spool/postfix/private/defer
/var/spool/postfix/private/maildrop
/var/spool/postfix/private/mailman
/var/spool/postfix/private/discard
/var/spool/postfix/private/anvil
/var/spool/postfix/private/scalemail-backend
/var/spool/postfix/private/bsmtp
/var/spool/postfix/private/bounce
/var/spool/postfix/private/verify
/var/spool/postfix/private/trace
/var/spool/postfix/private/uucp
/var/spool/postfix/private/lmtp
/var/spool/postfix/private/local
/var/spool/postfix/private/error
/var/spool/postfix/private/rewrite
/var/spool/postfix/private/proxymap
/var/spool/postfix/private/smtp
/var/spool/postfix/private/tlsmgr
/var/spool/postfix/private/scache
/var/spool/postfix/private/virtual
/var/spool/postfix/public/showq
/var/spool/postfix/public/qmgr
/var/spool/postfix/public/pickup
/var/spool/postfix/public/cleanup
/var/spool/postfix/public/flush
/var/spool/postfix/dev/log
I tried to restart the server by sudo service mysql start
but got this output
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
The output for systemctl status mysql.service
is
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Sun 2019-08-25 15:41:53 UTC; 27s ago
Process: 16974 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 16966 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCE
Main PID: 16974 (code=exited, status=1/FAILURE); : 16975 (mysql-systemd-s)
Tasks: 2
Memory: 5.1M
CPU: 331ms
CGroup: /system.slice/mysql.service
└─control
├─16975 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─17042 sleep 1
Aug 25 15:41:53 keshinpoint systemd[1]: Starting MySQL Community Server...
Aug 25 15:41:53 keshinpoint systemd[1]: mysql.service: Main process exited, code=exited, status=1/F
Feels like a rabbit hole here. Can someone please help me with this? I would be grateful for any guidance offered, as Ive tried answers from multiple stackoverflow posts.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×