cmd connects the local mysql database and the remote server mysql database

1. Connect to the local mysql database in the cmd window

Open the run window, enter cmd, and confirm

windows+r

 Or right click on the windows icon in the lower left corner and click the run button to open the run window

Format: mysql -u username -p password

mysql -uroot -p123456

 

 Successfully entered mysql

2. Connect to the mysql database of the remote server in the cmd window

Port 3306 needs to be opened in the security group of the server

Format: mysql -h domain name or ip address -u username -p password

mysql -hbaidu.com -uroot -p123456 # Connect to the mysql database whose domain name is baidu.com

Then you can operate on the database, such as:

query all databases

show databases;

 use database

use qubian;

 Query all tables in the database

show tables; 

 

 Query the data of a table

select * from course_userprofile;

Guess you like

Origin blog.csdn.net/qq_37140721/article/details/130243183