HTML, XHTML and CSS All-In-One for Dummies - Andy Harris [248]
Figure 1-1 provides an overview of the three-tier system.
Figure 1-1:
An overview of the three-tier data model.
Practicing with MySQL
MySQL is a server, so it must be installed on a computer in order to work. To practice with MySQL, you have a few options:
♦ Run your own copy of MySQL from the command line. If you have MySQL installed on your own machine, you can go to the command line and execute the program directly. This task isn’t difficult, but it is tedious.
♦ Use phpMyAdmin to interact with your own copy of MySQL. This solution is often the best. phpMyAdmin is a set of PHP programs that allows you to access and manipulate your database through your Web browser. If you’ve set up XAMPP, you’ve got everything you need. (See Book VIII for more information about XAMPP.) You can also install MySQL and phpMyAdmin without XAMPP, but you should really avoid the headaches of manual configuration, if you can. In this chapter, I do all MySQL through phpMyAdmin, but I show other alternatives in Book V(where you can connect to MySQL through PHP) and Chapter 2 of this minibook.
♦ Run MySQL from your hosting site. If you’re using Freehostia or some other hosting service, you generally access MySQL through phpMyAdmin.
Setting Up phpMyAdmin
By far the most common way to interact with MySQL is through phpMyAdmin. If you’ve installed XAMPP, you already have phpMyAdmin. Here’s how you use it to get to MySQL:
1. Turn on MySQL with the XAMPP Control Panel, shown in Figure 1-2.
You also need Apache running (because XAMPP runs through the server). You don’t need to run MySQL or Apache as a service, but you must have them both running.
Figure 1-2: I’ve turned on Apache and MySQL in the XAMPP control panel using the buttons.
2. Go to the XAMPP main directory in your browser.
If you used the default installation, you can just point your browser to http://localhost/xampp. It should look like Figure 1-3.
Don’t just go through the regular file system to find the XAMPP directory. You must use the localhost mechanism so that the PHP code in phpMyAdmin is activated.
3. Find phpMyAdmin in the Tools section of the menu.
The phpMyAdmin page looks like Figure 1-4.
4. Create a new database.
Type the name for your database in the indicated text field. I call my database xfd. (Xhtml For Dummies — get it?)
Figure 1-3: Locating the XAMPP subdirectory through localhost.
Figure 1-4: The phpMyAdmin main page.
Changing the root password
MySQL is a powerful system, which means it can cause a lot of damage in the wrong hands. Unfortunately, the default installation of MySQL has a security loophole you could drive an aircraft carrier through. The default user is called root and has no password whatsoever. Although you don’t have to worry about any pesky passwords, the KGB can also get to your data without passwords.
This section is a bit technical, and it’s pretty important if you’re running your own data server with XAMPP. But if you’re using an online service like Freehostia, you won’t have to worry about the data security problems described in this section. You can skip on to the section called “Using phpMyAdmin on a remote server.” Still, you’ll eventually need this stuff, so don’t tear these pages out of the book or anything.
Believe me, the bad guys know that root is the most powerful account on MySQL and that it has no password by default. They’re glad to use that information to do you harm (or worse, to do harm in your name). Obviously, giving the root account