Chapter 8. Using MySQL

Now that we’ve learned basic SQL information and the essentials of designing a database, it’s time to learn how to connect to the MySQL database using the client tools that come with MySQL. We’ll also cover how to use SQL to create databases, users, and tables, as well as to modify existing objects in the database.

MySQL Database

MySQL has its own client interface, allowing you to move data around and change database configuration. Note that you must use a password to log in. Assigning database users allows you to limit access to server tables that have multiple users. Each MySQL server, where tables are grouped together, can host many databases. Normally, a web application has its own proprietary database.

You may have installed MySQL yourself or have access through your ISP. Most ISPs that support PHP also provide a MySQL database for your use. Should you have difficulty, check their support pages or contact them to determine connection details. You’ll need to know the following:

  • The IP address of the database server

  • The name of the database

  • The username

  • The password

If you’ve installed MySQL on your computer, you’ll be able to use the defaults from the installation and the password you specified. This chapter looks at two ways to communicate with MySQL, the command line and phpMyAdmin, a web-based tool.

Accessing the Database with the Command Line

One way of communicating with MySQL is via the MySQL Command Line Client. Depending on which operating system you’re ...

Get Learning PHP and MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.