Microsoft Word - Sam's Teach Yourself MySQL in 21 Days - SAMS.doc

(singke) #1
respond to the shopper's requests don't store all the answers in their heads. They look up information
from available resources. This is much like the mysqld daemon It sits there—after it is started—waiting
for requests. Depending on the type of request, it will either answer it directly or use the database that
was asked for in the request. This is what makes an enterprise-level database different from a desktop
application.

Using MySQL in Linux


To use your database, the MySQL daemon has to be running. (If the server program is not running it cannot
respond to any requests). To start the server in Linux, make sure you are in the mysql directory and type
the following from the command line:


cd mysql
bin/safe_mysqld &
The safe_mysqld command starts the server. The ampersand, &, forces the program to run in the
background. There are several ways to ensure that your process is up and running. From the command
line, try the following:
cd mysql
bin/mysqladmin –p ping

You should then see
Enter password: Yourpassword <enter>
Mysqld is alive
The ping argument of the mysqladmin command is a quick and easy way to see if the mysql process
is running. Another technique is to actually check the system processes. To do this, type the following
from the command line:
ps –aux |grep mysql
If mysqld is running, you will see an instance of it here.
The safe_mysqld command is the best way to start your engine. It will automatically restart itself if it
goes down. You can start MySQL by using the mysqld command. This is not recommended in
production environments because it does not automatically restart itself.
To stop the with the shutdown argument, as shown in the following:
cd mysql
bin/mysqladmin -p shutdown
This will safely shut down the engine. A more drastic way of stopping the engine is to use the kill
command. This is not recommended because it can cause corruption of your data.
As with most server daemons, it is recommended that you start this process when the server is started
and stop it when the server is stopped. To do this, use the mysql.server script with the start
argument (mysql.server start) located in the support files directory. Use this script in the rc.d
directory. Refer to your brand of Linux's documentation to do this correctly.

Using MySQL with Windows


Like Linux, the MySQL server runs as a background process. To start the server on a Windows platform,
double-click the mysqld.exe file in the \mysql\bin directory. This will start the process.
To stop the service, run the mysqladmin shutdown from the DOS prompt. This will take the server
process down gracefully. The more drastic, possibly harmful way is to use the Task Manager to shut the
process down. This could cause data corruption and is not recommended.


It is also worth mentioning that, unlike the Linux daemon, the Windows process has a small memory
leak. After time, this small leak will cause problems. The system will lock up and programs will not run.
To fix this problem, reboot the machine every couple of weeks. According to the documentation, the
TcX development team has fixed this problem and it will be corrected in the next release.
To have Windows NT start this process automatically, go to the Control Panel and click Services. You
should see the mysqld service. Check it to start automatically. On Windows 95/98, you must place the
mysqld.exe command in the Startup directory.
Free download pdf