Revised installation instructions for PHP, Apache & MySQL
Setting the root password on MySQL (Mac OS X)
Many apologies to Mac users. When I wrote the Mac instructions in the Appendix, I (wrongly) assumed that Allan would show Windows users how to set up the root password with MySQL Monitor. This is how you do it:
- First of all, make sure you have added MySQL to your PATH, as described on pages 498-500.
- Open Terminal, and type the following command (followed by Return):
mysql -u root - You should see a welcome message like this:

- The most common problem is to instead get an error message like the following one:

It means that MySQL is not running. If you installed the MySQL Startup Item, the command to restart the MySQL server is
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
Enter your Mac password when prompted, and go back to step 2. - Assuming you have logged in successfully as described in step 2, type the following command at the
mysql>prompt (follow this and all subsequent commands with Return):
use mysql - You should see the message "Database changed", which means MySQL is ready for you to work on the files controlling administrative privileges. Now enter the command to set a password for the root user. Substitute myPassword with the actual password you want to use. Also make sure you use quotes where indicated and finish the command with a semicolon:
UPDATE user SET password = PASSWORD('myPassword') WHERE user = 'root'; - Next, remove anonymous access to MySQL:
DELETE FROM user WHERE user = ''; - Tell MySQL to update the privileges table:
FLUSH PRIVILEGES;
The sequence of commands should produce a series of results like this:
- To exit MySQL Monitor, type
exit. - To get back into MySQL Monitor in future, type the following command:
mysql -u root -p
and enter your password when prompted. - Congratulations, you have a secure installation of MySQL.
