MySQL Primer 
by Daniel Bartholomew

Intro | Logging In | Viewing | Inserting | Modifying | Links

<-- Previous

Logging Into MySQL

Next -->

Log into the server that has access to the MySQL database you want to use, often this is the same machine that is hosting the database, sometimes it isn't.


mysql -u username -ppassword -h host databasename

Replace username with your username, password with your password, host with the URI of the database server (can be localhost), and databasename with the name of the database you want to access.

Note that there is no space between -p and your password, if you put a space in there your password will not work.

If the copy of MySQL that you want to access is on the same machine as you, you can ignore the -h host argument. The mysql program will assume that you are logging in to a local database.

If your mysql username is the same as your computer login name, you can leave the -u username argument off.

If your login is successful you should see something that looks similar to this:

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is xxxxx to server version: x.xx.xx
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

The mysql> prompt is what we are interested in. The is where you will enter in all of your SQL statements. More about those on the next page.

<-- Previous

Next -->

Creative Commons License
This work is licensed under a Creative Commons License.