Bobcares

‘mysql unrecognized service’ error – Why you can’t connect to MySQL?

by | Jan 2, 2019

MySQL errors become bothersome, when you have to spend your entire business day solving these errors.

One such annoying error is “mysql unrecognized service“.

Server owners often see this error after installing MySQL, upgrading, etc.

At Bobcares, we help customers solve such MySQL errors as part of our Server Support Services to our web hosts.

Today, we’ll discus the top 4 reasons for this error and how we fix them.

 

What is ‘mysql unrecognized service’ error?

Simply put, ‘mysql unrecognized service‘ means that there is no MySQL service on the server.

It could be that there is no MySQL server on your system, or your MySQL server is named something else, or your system uses another method to start MySQL.

And, users see this error when trying to start or restart the MySQL service.

# sudo service mysqld start
mysqld: unrecognized service

 

‘mysql unrecognized service’ error – Top 4 causes and Fixes

Let’s now discuss the main reasons for this error in detail and how our Server Support Engineers fix them.

1) Missing/Corrupted MySQL server package

This is one of the common errors made during the installation process of MySQL by server owners.

For example, server owners simply use “yum install mysql” command to install MySQL service on their CentOS servers.

In most cases, the required MySQL files get partially installed in the server.

In other words, this will sometimes fail to install the mysql-server and mysql-devel files packages.

As a result, users see this error when they try to start the service.

 

How we fix?

Firstly, our Hosting Engineers check if the MySQL installation on the server is correct or not.

For instance, in CentOS servers, we use the below command to check whether the required MySQL packages are installed or not.

yum list installed | grep MySQL

 

If we find missing packages, we’ll install them manually .

In most cases, mysql-server and mysql-devel files are missing and we install them to fix the problem.

yum install mysql-server
yum install mysql-devel

 

[Is your MySQL installation corrupted or incomplete? Don’t panic, our Server Administrators are here to help you.]

2) Incorrect permissions/ownership of MySQL

This problem usually occurs after the customer has made server updates.

MySQL data directory and socket requires specific permissions and ownership for the service to work well. If there is any mismatch in these parameters, MySQL will not be able to access the data files.

Sometimes, the permissions and ownership of the MySQL service can be changed as part of the updates. And, the limited permissions disallow mysqld service to be executed.

As a result, users see this error when they try to start or restart MySQL service.

How we fix?

Our Hosting Engineers first check the server logs and database error logs.

And, if any permission or ownership related errors are noted, we’ll immediately correct it.

Most importantly, we ensure that the files in /var/lib/mysql have 770 permissions and ownership set to mysql.

We enure the above points using the below commands.

chmod -R 770 /var/lib/mysql
chgrp -R mysql /var/lib/mysql

 

In addition to that, our Support Engineers ensure that the /etc/rc.d/init.d/mysqld script has executable permissions to modify mysqld.

chmod 755 /etc/rc.d/init.d/mysqld

 

[Struggling with permissions and ownership of MySQL files in your server? Our MySQL experts can fix it in minutes.]

 

3) Wrong service name

The name of the MySQL service provided by official RPMS of MySQL is mysql.

On the other hand, in the packages provided by CentOS, the MySQL service is named as mysqld.

Sometimes, server owners use the wrong service name when starting/restarting the service, and they get “mysql unrecognized service” error.

 

How we fix?

Our Support Engineers first check the correct name of the service on the server.

For example, we use the below command to list all the services on the system and identify the correct service name.

chkconfig --list

 

Once we identify the correct service, we start the service on the server.

For example, we start the mysql service on CentOS 7 server using the below command.

systemctl start mysqld

 

4) AppArmor configuration

AppArmor is a security module that brings restrictions on services by configuring custom profiles.

Any corruption or misconfiguration in these profiles may lead to errors.

We’ve seen cases where users change MySQL database directory to a custom one, but forgot to add it in the AppArmor custom profiles.

How we fix?

In cases where the error is due to AppArmor profiles being corrupt, we recreate the profiles, correct and fix the related configuration issues.

If any customization is made in any of the services, we ensure that these changes are reflected in the AppArmor profiles.

 

Conclusion

In short, ‘mysql unrecognized service’ error may occur due to missing MySQL packages, incorrect MySQL service permissions, and more. Today, we’ve discussed the top 4 reasons for this error and how our Server Support Engineers fix it.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

SEE SERVER ADMIN PLANS

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

1 Comment

  1. Nitin

    Thank you so much!
    Finally, after going through a lot of not so helpful articles, I got you.

    You guys are great!

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.