Basic MySQL Troubleshooting



Basic MySQL Troubleshooting

You can confirm whether your MySQL installation has succeeded by performing these few simple steps.

Connectivity Testing

In the example scenario, network connectivity between the database and the application will not be an issue because they are running on the same server.

In cases where they are not, you have to use the troubleshooting techniques in Chapter 4, "Simple Network Troubleshooting," to test both basic connectivity and access on the MySQL TCP port of 3306.

Test Database Access

The steps outlined earlier are a good test of database access. If the application fails, then retrace your steps to create the database and register the database information into the application. MySQL errors are logged automatically in the /var/log/mysqld.log file; investigate this file at the first sign of trouble. Sometimes, MySQL will fail to start because the host table in mysql database wasn't created during the installation; this can be rectified by running the mysql_install_db command.

A Common Fedora Core 1 MySQL Startup Error

You may notice that you can start MySQL correctly only once under Fedora Core 1. All subsequent attempts result in the message "Timeout error occurred trying to start MySQL Daemon."

     [root@bigboy tmp]# /etc/init.d/mysqld start
     Timeout error occurred trying to start MySQL Daemon.
     Starting MySQL: [FAILED]
     [root@bigboy tmp]#

This is caused by the MySQL startup script incorrectly attempting to do a TCP port ping to contact the server. The solution is:

1.
Edit the script /etc/rc.d/init.d/mysqld.

2.
Search for the two mysqladmin lines with the word "ping" in them, and insert the string "-u $RANDOM" before the word "ping:"

     if [ -n "`/usr/bin/mysqladmin -u $RANDOM ping 2> /dev/null`" ]; then
     if !([ -n "`/usr/bin/mysqladmin -u $RANDOM ping 2> /dev/null`" ]); then

3.
Restart MySQL.

After doing this, MySQL should function correctlyeven after a reboot.