Most people run their database servers all of the time. After all, it makes no sense to have a database if you cannot get to the data. TcX created MySQL with this in mind and thus MySQL runs as a daemon process under Unix or as a service under Windows NT. Windows 9x has only the rough analog of sticking a shortcut to the executable in the StartUp folder. One important issue to note under Windows 95 specifically is that Windows 95 leaks about 200 bytes of main memory for each thread creation. You therefore do not want to leave MySQL running under Windows 95 for extended periods of time. This problem does not apply to Windows 98 or Windows NT.
You run MySQL using the /usr/local/bin/safe_mysqld by default. This script is a Bourne script you can edit in order to change any of the default values. Any options that you supply to safe_mysqld will be passed on to the MySQL daemon itself.
MySQL is a forking daemon. As soon as you launch it, the program creates a copy of itself (forks itself) and runs as a background process. You thus do not need to do anything special to get MySQL to run in the background. If you use the wrapper safe_mysqld to start MySQL, then you do need to put it in the background:
/usr/local/mysql/bin/safe_mysqld &
The reason you need to run safe_mysqld in the background -- and the reason you should run it instead of directly running mysqld -- is that the safe_mysqld script starts mysqld and then continuously verifies that mysqld stays running. If MySQL dies unexpectedly, safe_mysqld will restart it.
Now that you know how to start MySQL, you need to get MySQL to start up and shut down with the computer on which it runs. Under Windows NT, of course, installing MySQL as a service is sufficient for the task. Under Windows 9x, you have to stick a shortcut to the MySQL startup script in the StartUp folder. As with just about everything else in the Unix world, getting MySQL to run at system startup and shut down at system shutdown is more complicated. Unix systems generally look for startup scripts somewhere under the /etc directory -- some under /etc/rc.d or /etc/init.d. You should check with your system administrator or system documentation for the exact details of where your startup/shutdown script should go. The MySQL distribution comes with a file in the support_files directory called mysql.server. This Unix shell script will serve as your startup/shutdown script.
Copyright © 2001 O'Reilly & Associates. All rights reserved.