HomeDatabaseMySQLConnect to a MySQL server using the mysql command

Connect to a MySQL server using the mysql command

The mysql command provides a text-based interface into the MySQL database server. Once connected, SQL commands can be issued to the server to make queries, create or alter databases or tables, or many other operations.


To connect to the MySQL server on the local system, issue the following command:

mysql -u username -p
Enter password: *******

Where username is the name of a user authorized to use the database (see Create a MySQL user account). The -p option will prompt for the user’s password as shown below the command.

If the MySQL server resides on a remote host, the mysql command, if present on the local system, can be used to connect to the MySQL server accross the network. To connect to a MySQL server on a host named ‘elephant’ use the following command:

mysql -h elephant -u username -p

Quinn McHenry
Quinn McHenry
Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

LATEST REVIEWS

Recent Comments

error: Content is protected !!