Question

trying to install mysql but I cannot start the service and cannot locate mysqld.sock

I’m trying to install mysql but I cannot start the service and cannot locate mysqld.sock

I am following the how to here: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04

And get stuck trying to run $ mysql_secure_installation

I get this error:

Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Checking the version does show it installed.

mysql --version
mysql  Ver 8.0.21-0ubuntu0.20.04.4 for Linux on x86_64 ((Ubuntu))

I am unable to locate the mysqld.sock file anywhere and there is also no mysqld dir in /var/run/

I’ve also been through this troubleshooting doc https://www.digitalocean.com/community/tutorials/how-to-troubleshoot-socket-errors-in-mysql

But I can’t start the mysql service and there is nothing in the mysql.cnf file other than this

# The MySQL database client configuration file
#
# Ref to https://dev.mysql.com/doc/refman/en/mysql-command-options.html

[mysql]

This is what mysql.service shows

systemctl status mysql.service
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: activating (start) since Thu 2020-09-10 14:31:23 UTC; 15s ago
    Process: 8847 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 8855 (mysqld)
     Status: "Server startup in progress"
      Tasks: 4 (limit: 533)
     Memory: 2.5M
     CGroup: /system.slice/mysql.service
             └─8855 [mysqld]

If I run it again the Process / Main PID changes. Does that mean it’s just taking a while to complete and I need to be patient?

I’ve uninstalled mysql a few different times but can’t seem to get it sorted.

Any help appreciated.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Accepted Answer

Hi there @dezshredder,

To me it looks like that your MySQL service is stuck in a crash loop as the status output that you’ve shared indicates that the status is: "Server startup in progress" and the uptime is 15 seconds.

I would recommend checking your MySQL error log for more information on what might be wrong.

Also, I could suggest checking your /var/log/syslog log for more information as well.

Feel free to share the errors from the logs here so that I could try to advise you further.

Regards, Bobby

Bumping up the Droplet did the trick!

I’m up and running.

Guess that’s what I get for being frugal and going with the cheapest option.

Thanks for the help @bobbyiliev!

Yeah something is definitely stuck.

tailing syslog shows mysql restarting over and over

Sep 11 15:15:15 ubuntu-s-1vcpu-512mb-nyc1-01 kernel: [ 1598.053913] [   2123]     0  2123     2743      723    61440        0             0 sudo
Sep 11 15:15:15 ubuntu-s-1vcpu-512mb-nyc1-01 kernel: [ 1598.053914] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/system.slice/mysql.service,task=mysqld,pid=2058,uid=112
Sep 11 15:15:15 ubuntu-s-1vcpu-512mb-nyc1-01 kernel: [ 1598.053966] Out of memory: Killed process 2058 (mysqld) total-vm:1231176kB, anon-rss:326860kB, file-rss:0kB, shmem-rss:0kB, UID:112 pgtables:968kB oom_score_adj:0
Sep 11 15:15:15 ubuntu-s-1vcpu-512mb-nyc1-01 kernel: [ 1598.088100] oom_reaper: reaped process 2058 (mysqld), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
Sep 11 15:15:15 ubuntu-s-1vcpu-512mb-nyc1-01 systemd[1]: mysql.service: Main process exited, code=killed, status=9/KILL
Sep 11 15:15:15 ubuntu-s-1vcpu-512mb-nyc1-01 systemd[1]: mysql.service: Failed with result 'signal'.
Sep 11 15:15:15 ubuntu-s-1vcpu-512mb-nyc1-01 systemd[1]: Failed to start MySQL Community Server.
Sep 11 15:15:15 ubuntu-s-1vcpu-512mb-nyc1-01 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 19.
Sep 11 15:15:15 ubuntu-s-1vcpu-512mb-nyc1-01 systemd[1]: Stopped MySQL Community Server.
Sep 11 15:15:15 ubuntu-s-1vcpu-512mb-nyc1-01 systemd[1]: Starting MySQL Community Server...

It went from restart count 17 to 24 while writing this response.

Also load is very high on this droplet. htop shows average of 3.96

I also rebooted the whole droplet when I saw the load so high but it just started climbing again presumably due to mysql issues.

Thanks for the help @bobbyiliev .

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel