Mysql connect to database

Method 1

After installation, you can find the command line terminal operation of MySQL Command Line click operation in the list of the start menu. The effect is as shown in the figure:

image

Method 2

If it is added to the Windows environment variables, it can be operated directly from the command line.

In the command line, you can connect to the database server through the following command:

mysql -h localhost -u root -p

The above command Medium: mysql represents the mysql database startup tool.

Parameter description:

ParameterDescription
-h represents the database connection address. You can leave it blank when connecting to the local computer.
-u represents the user to log in
-p means using password to log in

Note: Usually we do not enter the password directly. Instead, enter your password after pressing Enter. Because the characters when entering the password are invisible, you can directly press Enter to log in after entering the password. Prevent someone nearby from taking away important passwords.

If there are no other problems, the following content will appear after successful login:

mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.25 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

The Chinese meaning above translates to "Welcome to use MySQL's command line operation tool." At the end of each command, you can enter \g or ;

mysql is currently connected for the 7th time.

The current database version is the 5.6.25 community support version. Follow the GPL agreement.

Copyright: 2000 to 2015. Owned by Oracle and its subsidiaries.

If you need help, use the ‘help;’ or ‘\h’ command to display the help content, and use the ‘\c’ command to clear the command line history.

mysql>

mysql > means waiting for input instructions.


Note:

There is such a prompt after successful login, which may not be understood by everyone:

Your MySQL connection id is 7

Indicates the 7th connection login, and the ID is incremented by 1 for each login. The next display will be the 8th time.

You can try it out:)

Continuing Learning
||
submitReset Code