• On Unix, set the MYSQL_UNIX_PORT  and MYSQL_TCP_PORT  environment variables to point to the Unix socket file and TCP/IP port number before you start your clients. If you normally use a specific socket file or port number, you can place commands to set these environment variables in your .login file so that they apply each time you log in. See Section 4.9, “Environment Variables” . 

•Specify the default Unix socket file and TCP/IP port number in the [client]  group of an option file. For example, you can use C:\my.cnf  on Windows, or the .my.cnf  file in your home directory on Unix. See Section 4.2.2.2, “Using Option Files” . 

•In a C program, you can specify the socket file or port number arguments in the mysql_real_connect()  call. You can also have the program read option files by calling mysql_options() . See C API Basic Function Descriptions. 

•If you are using the Perl DBD::mysql  module, you can read options from MySQL option files. For example: 

$dsn = "DBI:mysql:test;mysql_read_default_group=client;" . "mysql_read_default_file=/usr/local/mysql/data/my.cnf"; $dbh = DBI->connect($dsn, $user, $password); 

See Section 29.9, “MySQL Perl API” . 

Other programming interfaces may provide similar capabilities for reading option files. 

## 5.9 Debugging MySQL 

This section describes debugging techniques that assist efforts to track down problems in MySQL. 

## 5.9.1 Debugging a MySQL Server 

If you are using some functionality that is very new in MySQL, you can try to run mysqld  with the --skip- new  option (which disables all new, potentially unsafe functionality). See Section B.3.3.3, “What to Do If MySQL Keeps Crashing” . 

If mysqld  does not want to start, verify that you have no my.cnf  files that interfere with your setup! You can check your my.cnf  arguments with mysqld --print-defaults  and avoid using them by starting with mysqld --no-defaults ... . 

If mysqld  starts to eat up CPU or memory or if it “hangs,”  you can use mysqladmin processlist status  to find out if someone is executing a query that takes a long time. It may be a good idea to run mysqladmin -i10 processlist status  in some window if you are experiencing performance problems or problems when new clients cannot connect. 

The command mysqladmin debug  dumps some information about locks in use, used memory and query usage to the MySQL log file. This may help solve some problems. This command also provides some useful information even if you have not compiled MySQL for debugging! 

If the problem is that some tables are getting slower and slower you should try to optimize the table with OPTIMIZE TABLE  or myisamchk . See Chapter 5, MySQL Server Administration . You should also check the slow queries with EXPLAIN . 

You should also read the OS-specific section in this manual for problems that may be unique to your environment. See Section 2.1, “General Installation Guidance” . 

## 5.9.1.1 Compiling MySQL for Debugging 

If you have some very specific problem, you can always try to debug MySQL. To do this you must configure MySQL with the -DWITH_DEBUG=1  option. You can check whether MySQL was compiled 

