Question

How To Configure Mysql Server

#I have just installed Mysql server on Ubuntu 22.04 but everytime I try to start it I am experiencing errors:

-When I try to launch it using “sudo mysql” in the terminal I get the following error:

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

-Using “sudo service mysql start” in the terminal I get:

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.

-When I run “systemctl status mysql service” I get the following output:

Unit service.service could not be found. × mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; disabled; preset: enabled) Active: failed (Result: exit-code) since Thu 2023-01-12 11:41:02 UTC; 22s ago Process: 32000 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE) CPU: 5ms

Jan 12 11:41:02 appdev systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5. Jan 12 11:41:02 appdev systemd[1]: Stopped MySQL Community Server. Jan 12 11:41:02 appdev systemd[1]: mysql.service: Start request repeated too quickly. Jan 12 11:41:02 appdev systemd[1]: mysql.service: Failed with result ‘exit-code’. Jan 12 11:41:02 appdev systemd[1]: Failed to start MySQL Community Server.

#SO how can I solve this problem? Please help


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.

Bobby Iliev
Site Moderator
Site Moderator badge
January 12, 2023

Hi there,

I’ve just tried this on a fresh new Ubuntu 22.04 Droplet and I installed MySQL with the following command:

sudo apt update -y
apt install mysql-server mysql-client

And then I was able to access MySQL with the following command:

mysql -h localhost

In your case, I would recommend checking the MySQL error log so that you could see what might be causing the problem. You can check the log with the following command:

tail -100 /var/log/mysql/error.log

Let me know how it goes!

Best,

Bobby

alexdo
Site Moderator
Site Moderator badge
January 13, 2023

Hello @chiefagibu

Just to add something to what have already been mentioned. We have a tutorial on accessing MySQL error logs and troubleshooting MySQL errors which you can check here:

https://www.digitalocean.com/community/tutorials/how-to-access-mysql-error-logs

https://www.digitalocean.com/community/tutorial_series/how-to-troubleshoot-issues-in-mysql

Regards

Try DigitalOcean for free

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

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

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

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
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
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

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

© 2023 DigitalOcean, LLC.