Accessing MySQL via the Command Line

There are three main ways in which you can interact with MySQL: using a command line, via a web interface such as phpMyAdmin, and through a programming language like PHP. We’ll start doing the third of these in Chapter 10, but for now, let’s look at the first two.

Starting the Command-Line Interface

The following sections describe relevant instructions for Windows, Mac OS X, and Linux.

Windows users

If you installed the EasyPHP WAMP as explained in Chapter 2, you will be able to access the MySQL executable from the following directory:

\Program Files\EasyPHP 3.0\mysql\bin

Note

If you installed EasyPHP in a place other than \Program Files, you will need to use that directory instead. Also, if the version of EasyPHP is not 3.0, you will need to change that, too.

By default, the initial MySQL user will be root and will not have had a password set. Seeing as this is a development server that only you should be able to access, we won’t worry about creating one yet.

So, to enter MySQL’s command-line interface, select Start→Run and enter CMD into the Run box, then press Return. This will call up a Windows Command prompt. From there, enter the following (making any appropriate changes as discussed previously):

"\Program Files\EasyPHP 3.0\mysql\bin\mysql" -u root

Note

Note the quotation marks surrounding the main path and filename. These are present because the name contains spaces, which the Command prompt doesn’t correctly interpret, and the quotation marks group ...

Get Learning PHP, MySQL, and JavaScript 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.