Page 388 - Beginning PHP 5.3
P. 388
Part III: Using PHP in Practice
WampServer menu, then choose the Start All Services or Restart All Services option to start both
the Apache and MySQL servers
❑ MAMP on Mac OS X — Open the MAMP folder inside your Applications folder in Finder, then
double - click the MAMP icon to launch the application. If the MySQL server has a red light to the
left of it, click the Start Servers button to start up both the Apache and MySQL servers. Both
lights should now be green
Setting Up the MySQL root Password
Now that the MySQL database engine is running on your computer, it ’ s time to configure the MySQL
root user.
MySQL, like most networked systems, requires you to log in with a specific user account before doing
anything else. This is a fairly obvious security measure, and it limits access to the data by specifying
permissions for each account. For example, one user may only have permission to view existing data,
whereas another may have permission to add new data, and perhaps even change other users ’
permissions.
root is the name traditionally given to a system ’ s most senior user, who automatically has permission to
view and modify all data and settings: a powerful position to be in. When MySQL installs, it creates the
root account automatically, but doesn ’ t set a password for it. This means that anyone can connect to
your server as root ! So your pristine MySQL server could be wide open to use and abuse by anyone
with a MySQL client and a network connection to the server, and you need to do something about that.
The process of setting the root password can seem a bit long - winded, especially if you ’ re unfamiliar
with MySQL, but it ’ s fairly straightforward, and you only have to do it once!
To set up a root password, follow these steps:
1. Bring up a shell prompt — On Ubuntu, choose Applications Accessories Terminal. On
Windows, choose Start All Programs Accessories Command Prompt. On the Mac, double -
click the Terminal icon inside your Applications/Utilities folder.
2. Change to the correct folder — In the Terminal or Command Prompt window, use cd to change to
the directory containing the MySQL command - line tool, mysql . With WampServer on Windows,
this should be something like C:\wamp\bin\mysql\mysql5.0.51b\bin . So you ’ d type:
cd C:\wamp\bin\mysql\mysql5.0.51b\bin
and press Enter.
When using MAMP on Mac OS X, assuming you installed MAMP inside your Applications
folder, the correct directory should be /Applications/MAMP/Library/bin . If you ’ re using
Ubuntu, you should be able to skip this step, because mysql is usually installed in the standard
path /usr/bin .
3. Start the MySQL command - line tool — On Ubuntu and Windows, type
mysql -u root
350
9/21/09 9:11:11 AM
c12.indd 350
c12.indd 350 9/21/09 9:11:11 AM