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.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF