MySQL login [database system]

1. Stop and start the service

After MySQL is installed, the server process needs to be started, otherwise the client cannot connect to the database.

 --- Run Windows Command Prompt as administrator, otherwise access is denied :

# 启动MySQL服务命令
net start MySQL服务名

# 停止MySQL服务命令
net stop MySQL服务名

1. The MySQL service is in a stopped state:

 

2. Start the MySQL service:

 3. The MySQL service is in the started state:



 The service name after start and stop should be the same as the service name specified in the previous configuration of the environment variable.

2. Login and logout

Format:

mysql -h 主机名 -P 端口号 -u 用户名 -p密码

Example:

mysql -h localhost -P 3306 -u root -pabc123  # 之前设置的root用户的密码是abc123

Landed successfully:

 Here comes the warning, just need to change the way the password is entered:

Exit command:

 

 

 Notice:

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

mysql -hlocalhost -P3306 -uroot -pabc123

(2) It is recommended to enter the password on the next line to ensure security.

(3) The client and server are on the same machine, so enter localhost or the IP address 127.0.0.1. At the same time, because it is connected to the machine: -hlocalhost can be omitted, if the port number has not been modified: -P3306 can also be omitted.



Before logging in, you can go through:

mysql -V

or

mysql --version

 way to obtain information about the MySQL Server service version.


After logging in through

select version();

View current version information. 

 

Guess you like

Origin blog.csdn.net/zhangxia_/article/details/123996101