I am very weak on unix shell scripting. Is there a way to create Unix shell script which will start on server boot time only, and will execute the following commands in order:
# cd /mysql
# ./bin/safe_mysqld --user=root &
# ./support-files/mysql.server start
The longer story... On a HP-UX server I've installed Mysql. However the client wanted the server to be installed in /mysql
instead in /usr/local/mysql/
which is the standard location. During the last week I've been struggling to set the mysql daemon to start automatically on server boot time.
I don't know what is the problem, but so far the only way to start the server is by using the above commands.
UPDATE: 07.02.12 15:23
This is a short output from the server boot when it starts the processes:
Start MySQL Server .................................................. OK
...
However after i enter ps -ef
I can easily tell that it is not started:
# ps -ef | grep -i mysql
root 3074 3056 0 15:26:53 pts/0 0:00 grep -i mysql
#
And this is how it should look like when i start the process:
# cd mysql
# ./bin/safe_mysqld --user=root &
[1] 3123
# Starting mysqld daemon with databases from /mysql/data
#
# ./support-files/mysql.server start
Starting MySQL
SUCCESS!
#
# ps -ef | grep -i mysql
root 3139 3123 0 15:27:19 pts/0 0:00 /mysql/bin/mysqld --basedir=/mysql --datadir=/mysql/data --u
root 3123 3056 0 15:27:19 pts/0 0:00 /bin/sh ./bin/safe_mysqld --user=root
root 3171 3056 0 15:27:59 pts/0 0:00 grep -i mysql
#
Now I think that it is more clear why I want to create a shell startup script and actually FORCE the starting of the process with those commands.
The binary needs to know the location of the my.cnf file at startup (a default will be compiled in). You didn't say what path prefix you used when building mysql. In turn the my.cnf file defines the locations of the data files.
It would be a good idea to use a proper SysV init script to manage the server. In addition to solving the problem of startnig the server at boot, you'll also get a clean shutdown when the system is halted, you can configure sensible behaviour for different runlevels and stop/start the mysql server alone in a managed way. And if you set it up correctly it will play nicely with SAM.
There's an example here (note that the location of my.cnf is passed as an argument to safe_mysqld). This should be in /sbin/init.d with appropriate (symbolic) links in /sbin/rcX.d (where X is the relevant runlevel). The process is described here.
I think the cleanest thing, if this is an option for you, is to recompile MySQL.
In the source directory (extract from tarball):