Embracing chkconfig to auto-start services (like mysql) on RHEL/CentOS/Fedora/etc.

I was at MODM4 yesterday, and as always, great fun was had. One common recurring theme though, was getting MySQL to start automatically upon a Linux server’s restart, something which I would have thought just came pretty naturally to sys-admin types. Upon further probing, these systems were all generally CentOS or RHEL based, and it wasn’t just MySQL that gave them problems – it was anything they’d installed out of the stock packages (lighttpd was a popular Apache replacement, that suffered from the same fate).

While I didn’t recollect the exact part of the manual it was stored in, I was informing everyone to make use of the chkconfig tool. Its really as simple as making sure there exists a /etc/init.d/mysql (it must be executable – chmod +x), doing a chkconfig --add mysql and making sure that it starts up at the correct runlevels (typically 3, 4 and 5). A simple chkconfig --level 345 mysql on and you’re ready to rock. Repeat, rinse for lighttpd or anything else, that has a startup script, really.

And read the manual – section Starting and Stopping MySQL Automatically. chkconfig‘s manual page is a little sparse, so consider some of the Red Hat Knowledgebase entries: How do I use chkconfig to enable a script for a service that accepts start, stop, and status options? and Why does an installed service, like ypbind, not show up in the chkconfig list, but I am able to start it manually? Kudos to Red Hat’s open KB as well…

Technorati Tags: , , , ,

Related posts:

  1. Updating PHP in RHEL/CentOS 5.6 for WordPress 3.2
  2. CentOS, CentOSPlus, and MySQL versions shipping there
  3. Using MariaDB on CentOS 6
  4. Zimbra claims ZCS 5.0 issues are the fault of CentOS
  5. MySQL in RHEL5/CentOS5 gets an update
  • Pingback: Colin Charles Agenda » Blog Archive » Switcher Guides

  • paul

    minor correction, should be:

    chkconfig –-level 345 mysqld on


  • Nico

    Excellent! Thank you very much.
    Was wasting my time trying to solve the same silly thing.

  • Manjula

    Let me know how to auto start mysql in fedora 10

  • Nico

    Excellent! Thank you very much.
    Was wasting my time trying to solve the same silly thing.