Home  >  Article  >  Database  >  What are the ways to log in to MySQL from the command line?

What are the ways to log in to MySQL from the command line?

王林
王林forward
2023-05-31 13:14:148244browse

Method 1:

Start Menu-> All Programs-> MySQL -> MySQL Server 8.0 -> MySQL 8.0 Command Line Client

What are the ways to log in to MySQL from the command line?

##Method 2: cmd command line client

mysql -h host name -P port number -u user name -p password

For example: mysql -h localhost -P 3306 -u root -proot

  • -h:host host name/IP address

  • ##-P:port port number
  • -u:user username
  • -p:password
  • Notes:

(1) There can be no spaces between -p and the password. There can be spaces or no spaces between other parameter names and parameter values.

mysql -hlocalhost -P3306 -uroot -proot

(2) It is recommended that the password be entered on the next line

mysql -h localhost -P 3306 -u root -p
Enter password:****

(3) If it is connected to the local machine: -hlocalhost can be omitted. If the port number has not been modified: -P3306 can also be omitted.

is abbreviated as:

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

(4) If the mysql command is entered, it will report "Not internal" Or external command", configure the bin directory of the mysql installation directory into the environment variable path

The above is the detailed content of What are the ways to log in to MySQL from the command line?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete