Connect to MySQL from the command line

2019-10-22 11:55:12 Raju Mysql

How to connect to MySQL from the command line?

To operate MySQL from the command line, you must first connect to MySQL.

Use the following mysql command to connect to MySQL Server.

mysql -u user name -D database name -p

The -u option specifies the username to connect to MySQL.

-D option specifies the name of the database to connect to.

Specify the -p option to send a password.

For example, to connect to the test database as the root user, execute the command as follows.

Since the root user has a password, the -p option is also added.

E: \ MySQL \ bin> mysql -u root -D test -p
Enter password: ***********
Welcome to the MySQL monitor.Commands end with; or \ g.
Your MySQL connection id is 1 to server version: 4.1.19-community-nt
Type 'help;' or '\ h' for help.Type '\ c' to clear the buffer.

If the connection is successful, the mysql prompt is displayed.

If you want to connect, run \ q to exit the prompt.

mysql> \ q

This post is submitted by one of our members. You may submit a new post here.

Related Tricks