Common mysql statements

Source: Internet
Author: User
Tags mysql command line

Common mysql statements

1. display the names of all tables in the current database (the prerequisite is that you must enter the database and enter the database statement: [use Database Name ;])
Mysql> show create table name;


2. Check which storage engines mysql supports:
Mysql> show engines;


3. view the default storage engine of mysql:
Mysql> show variables like '% storage_engine % ';

 

4. Back up a database[Used in windows cmd]

Mysqldump basic syntax [bold as the content ]:

  Mysqldump-hHostname-PPort-UUsername-PDbname table1 table2...>C: \ BackupName. SQL

Where:

  • Hostname Host Name: generally localhost or ip address of the host where the database is located (for example, 192.168.0.123)
  • Port: Generally, the default port 3306 may also be 3307 or another port.
  • Username: generally root
  • Dbname Database Name: for example, mytest (enter the name of the database to be backed up)
  • The table1 and table2 parameters indicate the name of the table to be backed up. If it is null, the entire database is backed up ;(Mysqldump-hLocalhostP3306-uRoot-P mytest>C :\Mytest. SQL orMysqldump-hLocalhost-P3306-uRoot-P mytest>C :\Mytest. SQL) The command-u-h-p and parameter can have spaces or do not contain spaces.
  • The path (absolute path) of the BackupName. SQL backup file is as follows: C :\Mytest. SQL indicates that the mytest. SQL file in drive C is a backup file.. SQL can be another suffix
  • -P indicates the password. Enter is required only after the command is entered.

Another example: Use the root user to back up the person table in the test Database

   mysqldump -u root -p test person > D:\backup.sql

5. Run the mysqldump command to restore the database. The syntax is as follows ]:

Mysql-hlocalhost-P3306-uroot-p dbname <C: \ mytest. SQL

  • Dbname is the name of the database to be restored: It means to restore the table structure and data of mytest. SQL to the dbname database.
  • The database must have been created
  • For other methods, you can also use the command sourceC: \ mytest. SQL [prerequisites: 1. Enter the command in the mysql command line; 2. Use current data;]

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.