Starting the MySQL server can be a common cause of problems, particularly when you go to install it for the first time. Your absolutely best first step should MySQL fail to start is to view the error log. It will record any messages indicating why MySQL could not be started. You can read logs in a text editor, or more easily in the MySQL Administrator (Figure A.3, see Chapter 13, "MySQL Administration").
Figure A.3. Use the MySQL Administrator to view your error logs.
Here are some common problems and solutions for starting MySQL:
If MySQL cannot find the data directory, set the value when you start mysqld using the --basedir=/path/to/mysql/data argument. You can also establish this in an option file.
If MySQL claims that it cannot find host.frm or mysql.host, it means that it cannot read the grant tables in the mysql database. Check that you ran the mysql_install_db script and that MySQL has permission to access the mysql files.
If you are running a firewall, this may prevent MySQL from starting. Turn off the firewall to confirm this is the problem. If so, allow MySQL's port (3306 by default) an exception in your firewall (Figure A.4).
Figure A.4. A firewall, like this one built into Windows, can cause complications unless you specifically allow MySQL access to port 3306.
On Windows, you can have difficulty starting MySQL as a service if there is a space in the pathname, e.g., C:\Program Files\MySQL\MySQL Server x.x, or if part of the pathname is too long. Either move into the MySQL directory and then execute the command, or use double quotation marks around the entire pathname.
On Unix and Mac OS X, to check if MySQL is already running, type ps ax | grep mysqld in a shell (Figure A.5).
Figure A.5. The command ps ax | grep mysqld should show that safe_mysqld and mysqld are running.