Page 389 - Beginning PHP 5.3
P. 389
Chapter 12: Introducing Databases and SQL
and press Enter. On Mac OS X, type:
./mysql -u root
(that ’ s a period, then a slash, then mysql , followed by a space, a hyphen, the letter “ u, ” another
space, and the word root ) and press Enter. You should see a message similar to the following
appear, indicating that you ’ re now running the mysql tool:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 671
Server version: 5.0.41 Source distribution
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql >
If you get an error along the lines of “ Access denied for user ‘ root’@’localhost ’
(using password: NO) ” , your MySQL server ’ s root account already has a password, and you ’ ll
need to enter the password using - (as shown in a moment). If you ’ ve forgotten the password, you can
p
reset it as described in a moment.
4. Inspect the current privileges — Enter the following at the mysql > prompt and press Enter:
SELECT Host, User, Password FROM mysql.user;
When entering SQL statements in the MySQL command - line program, you need to end each statement
with a semicolon.
You ’ ll see a list of the current users and passwords in the MySQL system, presented as a table.
It ’ ll probably look similar to the following:
+---------------+------+----------+
| Host | User | Password |
+---------------+------+----------+
| localhost | root | |
| mattscomputer | root | |
| 127.0.0.1 | root | |
| localhost | | |
| mattscomputer | | |
+---------------+------+----------+
5 rows in set (0.00 sec)
mysql >
You should see one or more rows with root in the User column, and an empty Password
column. You need to add a password to each one of those rows.
351
9/21/09 9:11:11 AM
c12.indd 351
c12.indd 351 9/21/09 9:11:11 AM