Question

Unable to install mysql-server on Ubuntu

Hello All,

I’m following the LAMP tutorial (https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-22-04), but I don’t seem to be able to install MySQL on Ubuntu 22.04 . I tried deleting my droplet, making a new one, and installing MySQL before anything else, but I still get the following after running “sudo apt install mysql-server”:

mysqld will log errors to /var/log/mysql/error.log
2022-07-11T19:20:59.707275Z 0 [ERROR] [MY-011065] [Server] Unable to determine if daemon is running: Invalid argument (rc=0).
2022-07-11T19:20:59.708151Z 0 [ERROR] [MY-010946] [Server] Failed to start mysqld daemon. Check mysqld error log.
Warning: Unable to start the server.
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Job for mysql.service failed.
See "systemctl status mysql.service" and "journalctl -xeu mysql.service" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: oom-kill) since Mon 2022-07-11 19:21:04 UTC; 36ms ago
    Process: 2778 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
    Process: 2786 ExecStart=/usr/sbin/mysqld (code=killed, signal=KILL)
   Main PID: 2786 (code=killed, signal=KILL)
     Status: "Server startup in progress"
        CPU: 1.229s
dpkg: error processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Setting up libcgi-pm-perl (4.54-1) ...
Setting up libhtml-template-perl (2.97-1.1) ...
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-8.0; however:
  Package mysql-server-8.0 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Setting up libcgi-fast-perl (1:2.15-1) ...
No apport report written because the error message indicates its a followup error from a previous failure.
                          Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3) ...
Errors were encountered while processing:
 mysql-server-8.0
 mysql-server
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

Thanks in advance for any advice

Show comments

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

I’ve just worked out it was due to a lack of memory on the Droplet, I upgraded from 512MB to 1GB , and it now installs fine

I had the same issue. I solved it using this stackoverflow post https://stackoverflow.com/a/68843792

i.e.

sudo -i
dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
swapon /swapfile
exit
sudo apt install mysql-server

DigitalOcean you should include a link to this in your LEMP/LAMP setup tutorials.

Try DigitalOcean for free

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

Sign up

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.