Login | Contact Us | Site Map | Resources

MYSQL Basics

Home > MYSQL Tutorial > Connecting & Disconnecting From the MySQL Server

Connecting & Disconnecting From the MySQL Server

From the command line, connecting to MYSQL may require knowledge of the host, the username and the password that are provided by the hosting company that you are using.

mysql -h host -u username -p

The above line starts out by naming the program we want to run (MYSQL). The "-h" part identifies the host, which will be provided by your hosting company and typed in the place of "host". The "-u" identifies the username, which is also provided by the hosting company and will replace the word "username". The "-p" part states that there is a password that needs to be entered, but notice that it is not entered here (for security reasons). Instead, after typing in this line and hitting the <enter> key, you will be prompted with something like this:

Enter password:

...And there you type in your password, where it will either not show up as you type it in, or show up as a series of asterisks * that keep passersby from reading your password. (unless they watched your fingers as you typed it in!)

After typing in your password and hitting <enter> again, you will be presented with a welcome screen similar to this:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 25338 to server version: 5.1.55-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

And you are ready to type in commands that can create databases, add information, update information, etc.

All commands that you type in will show up after the "mysql>".

When you are finished, simply type in "quit" and you will be signed out and returned to the original command prompt.

mysql> quit

Let's have some fun!