How do I access MySQL server from the shell prompt (command line)?
MySQL software includes mysql client. It is a text-based client for mysqld, a SQL-based relational database server.
Genreal syntax:
mysql -u {mysql-user} -p {mysql-password} -h {mysql-server}
Where,
- -u {mysql-user} : Specify MySQL user name. Use root only when connecting to local system.
- -p {mysql-password}: Specify password, Employ the specified password when connecting to the database server. If a password is not supplied, it will be requested interactively.
- -h {mysql-server}: Connect to the specified host (remote or local)
For example remote connect to MySQL server called mysql10.nixcraft.in and user vivek:
$ mysql -u vivek –h mysql10.nixcraft.in -p
Output
Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 to server version: 4.1.15-Debian_1-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Mysql user creation - setting up a MySQL new user account
- Howto: Use mysql or run mysql queries from shell script
- Import MySQL dumpfile, SQL datafile into my database
- MySQL Run SQL Queries From A Shell Prompt / Command Line
- MySQL startup script under BSD/Linux
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!


Recent Comments
Today ~ 1 Comment
Today ~ 3 Comments
Today ~ 57 Comments
Yesterday ~ 9 Comments
Yesterday ~ 7 Comments