1: Use the show statement to find out the current database on the server:
Mysql> show databases;
2. Create a database named mysqldata
Mysql> Create Database mysqldata;
3: select the database you created
Mysql> Use mysqldata; (when you press the Enter key to see database changed, the operation is successful !)
4: view the tables in the current database
Mysql> show tables;
5. Create a database table
Mysql> Create Table mytable (name varchar (20), sex char (1 ));
6: display the table structure:
Mysql> describe mytable;
7. Add records to the table
Mysql> insert into mytable values ("hyq", "M ");
8: load data into database tables in text mode (for example, D:/mysql.txt)
Mysql> load data local infile "D:/mysql.txt" into Table mytable;
9: import the. SQL file command (for example, D:/MySQL. SQL)
Mysql> use database;
Mysql> source D:/MySQL. SQL;
10: delete a table
Mysql> drop table mytable;
11: Clear the table
Mysql> Delete from mytable;
12: Update table data
Mysql> Update mytable set sex = "F" where name = 'hyq ';
13. Back up the database
Mysqldump-u root Database Name> XXX. Data
14: Example 2: connect to MySQL on the remote host
Assume that the IP address of the remote host is 110.110.110.110, the user name is root, and the password is abcd123. Enter the following command:
Mysql-h110.110.110.110-uroot-pabcd123
(Note: you do not need to add spaces for u and root. The same applies to others)
3. Exit MySQL command: exit (Press ENTER)