Connect to a MySQL server using the mysql command

Home -> Database -> MySQL

32838 views

From the computer of: qmchenry (339 recipes)
Created: Dec 14, 2003     Updated: Jul 17, 2004


Add a comment

Add to:
Add to stumbleuponAdd to del.icio.usDigg itAdd to FURL

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

Subscribe to the Tech-Recipes Newsletter

You can get tips like this delivered in your email every week!

Enter your Email

We will never, ever sell your email address or spam you.





Related recipes:

  Display a list of databases on a MySQL server
  Solve: Can't connect to local MySQL server through socket /tmp/mysql.sock
  Create a MySQL database
  Describe the column structure of a MySQL table
  Select a MySQL database to use
  Drop or delete a table in MySQL
  Determine the version of MySQL server
  Create a MySQL user account
  Create a basic MySQL table
  Import CSV file directly into MySQL

 

Sponsored links

 

Login

Nickname

Password

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.