Post-Installation Setup Tasks - Page 8
January 3, 2002
No matter which operating system you're running, once PHP is installed and the MySQL server is in operation, the very first thing you need to do is assign a "root password" for MySQL. MySQL only lets authorized users view and manipulate the information stored in its databases, so you'll need to tell MySQL who is an authorized user, and who isn't. When MySQL is first installed, it's configured with a user named "root" who has access to do pretty much any task without even entering a password. Your first task should be to assign a password to the root user so that unauthorized users can't mess around in your databases.
It's important to realize that MySQL, just like a Web server or an FTP server, can be accessed from any computer on the same network. If you're working on a computer connected to the Internet that means anyone in the world could try to connect to your MySQL server! The need to pick a hard-to-guess password should be immediately obvious!
To set a root password for MySQL, type the following command in the bin directory of your MySQL installation (include the quotes):
To make sure MySQL has registered this change, you should tell it to reload its list of authorized users and passwords:
If this command returns an error message to tell you that access was denied, don't worry: this just means the password has already taken effect.
To try out your new password, request that the MySQL server tell you its current status:
Enter your password when prompted. You should see a brief message that provides information about the server and its current status. The "-u root" argument tells the program that you want to be identified as the MySQL user called "root". The "-p" argument tells the program to prompt you for your password before it tries to connect. The "status" argument just tells it that you're interested in viewing the system status.
If at any time you want to shut down the MySQL server, you can use the command below. Notice the usage of the same "-u root" and "-p" arguments as before:
With your MySQL database system safe from intrusion, all that's
left is to configure PHP. To do this, we'll use a text file
Save the changes to
You're done! Now you just need to test to make sure everything's working okay.