Getting MySQL to start automatically

Red Storm

Lifer
Oct 2, 2005
14,233
234
106
Topic pretty much says it all. I have MySQL installed on Solaris 10 (x86, 32-bit), and I'd like to know how to make MySQL autostart when the system boots. I'm quite new to UNIX in general and google has failed me here. Any help?

Edit: Okay, some more info. Looking at the mysql file under /etc/init.d it says:

"Usually this is put in /etc/init.d and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql. When this is done the mysql server will be started when the machine is started and shut down when the system goes down."


I checked both the rc0 and rc3 directories, and found no S99mysql or K01mysql files. I assume these are scripts. Do I need to create these scripts manually?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
The files in /etc/rcX.d are all symlinks back to the original script in /etc/init.d
 

Red Storm

Lifer
Oct 2, 2005
14,233
234
106
Okay, but the files were not there in the /etc/rcX.d directories. Do I need to create them myself, and if so, what should they contain?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Technically they contain nothing, they're just symlinks to the real script in /etc/init.d. If /etc/init.d/mysql start/stop successfully starts and stops MySQL you could just run 'ln -s ../init.d/mysql S99mysql' to create the start symlink and 'ln -s ../init.d/mysql K01mysql' to create the stop symlink in their respective directories.
 

Red Storm

Lifer
Oct 2, 2005
14,233
234
106
It works, thanks! :)

On a somewhat related note, I'm also looking for a similar solution with Apache Tomcat. Admittedly I haven't really researched it yet, but if you know of a way to have it auto start when the server boots, that would be fantastic.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
If Tomcat comes with a similar init script already written for you, you can do the same thing. If not, you'll have to find out if Solaris has a facility similar to rc.local in most Linux distributions and just put whatever startup commands you need in there.