Home > Database > Mysql Tutorial > 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?

王林
Release: 2023-05-31 13:14:14
forward
8274 people have browsed it

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
Copy after login

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

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

(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:******
Copy after login

(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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template