3

I've installed MySQL-server on my ubuntu 21 system, when i try to start MySQL-Server im getting Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xeu mysql.service" for details. it was working fine before I installed docker and run a MySQL on it

systemctl status mysql.service

mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:>
     Active: failed (Result: exit-code) since Sat 2022-01-22 18:32:17 IST; 7min>
    Process: 19128 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=>
    Process: 19136 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
   Main PID: 19136 (code=exited, status=1/FAILURE)
     Status: "Server startup in progress"
      Error: 13 (Permission denied)
        CPU: 313ms

Jan 22 18:32:17 Lenovo systemd[1]: mysql.service: Scheduled restart job, restar>
Jan 22 18:32:17 Lenovo systemd[1]: Stopped MySQL Community Server.
Jan 22 18:32:17 Lenovo systemd[1]: mysql.service: Start request repeated too qu>
Jan 22 18:32:17 Lenovo systemd[1]: mysql.service: Failed with result 'exit-code>
Jan 22 18:32:17 Lenovo systemd[1]: Failed to start MySQL Community Server.

journalctl -xeu mysql.service

░░ Subject: A stop job for unit mysql.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A stop job for unit mysql.service has finished.
░░ 
░░ The job identifier is 6908 and the job result is done.
Jan 22 18:32:17 Lenovo systemd[1]: mysql.service: Start request repeated too qu>
Jan 22 18:32:17 Lenovo systemd[1]: mysql.service: Failed with result 'exit-code>
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit mysql.service has entered the 'failed' state with result 'exit-code>
Jan 22 18:32:17 Lenovo systemd[1]: Failed to start MySQL Community Server.
░░ Subject: A start job for unit mysql.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit mysql.service has finished with a failure.
░░ 
░░ The job identifier is 6908 and the job result is failed.
ioeshu
  • 75
  • 1
  • 1
  • 5

5 Answers5

4

I tried this and it worked:

sudo apt autoremove --purge mysql-server\* mariadb-server\*
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql/
sudo mkdir -p /etc/mysql/conf.d
sudo apt install mysql-server

Note: make sure to backup your data, because these commands will erase all of your MySQL data.

JOHN kOECH
  • 41
  • 2
2

Try these commands

sudo mysqld_safe --defaults-file=/etc/my.cf

sudo chown -R mysql:mysql /var/lib/mysql

sometimes for some systems, when you give the below two commands it will show Not a directory if it shows cut the below two commands off and follow the next command.

/etc/init.d/mysqld start

/etc/init.d/mysqld stop

Finally, try this command

sudo systemctl restart systemd-logind

After the systemctl restart the system will hang and log out sometimes. If it logged out, log in again and

Run sudo systemctl start mysql.service it will work fine.

For further commands check the link here and check following commands on that website if above doesn't work for you

che
  • 61
  • 1
  • 11
0

I try same and got this:

systemctl status mysql.service
× mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2022-10-17 22:38:59 CEST; 1min 40s ago
    Process: 17421 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
        CPU: 8ms

Okt 17 22:38:59 install-web systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Okt 17 22:38:59 install-web systemd[1]: Stopped MySQL Community Server.
Okt 17 22:38:59 install-web systemd[1]: mysql.service: Start request repeated too quickly.
Okt 17 22:38:59 install-web systemd[1]: mysql.service: Failed with result 'exit-code'.
Okt 17 22:38:59 install-web systemd[1]: Failed to start MySQL Community Server.

I have reinstalled but that didn't help.

James Risner
  • 5,451
  • 11
  • 25
  • 47
  • 1
    This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32966833) – Bert Blommers Oct 23 '22 at 17:46
0

i tried below commands and issue resolved

sudo apt autoremove --purge mysql-server\* mariadb-server\*
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql/
sudo mkdir -p /etc/mysql/conf.d
sudo apt install mysql-server
0

I faced the same error for the Digitalocean Ubuntu droplet. The problem was I was using a 500MB RAM Droplet, and 500MB RAM was not enough to install the MySQL server. So I resized the droplet to 1GB RAM and it worked.

Chaitanya Mogal
  • 321
  • 1
  • 9