MySQL5.5/5.6 & mdash; overview of MySQL client program _ MySQL

Source: Internet
Author: User
MySQL5.55.6amp; mdash; amp; mdash; overview of the MySQL client program bitsCN. comMySql client program
  • Mysql
  • Mysqladmin
  • Mysqlcheck
  • Mysqldump
  • Mysqlimport
  • Mysqlshow
  • Mysqlslap
  • References

 

Mysql

MysqlIs an SQL shell that can be input rows, and the input row can be edited. It supports interaction and non-interaction. When interactive queries are used, the query results are displayed in an ASCII table. When non-interactive (for example, filtering) is used, the query results are displayed in tab-separated format. The output format can be changed using the command line option. As follows:

shell> mysql db_name;

Or

shell> mysql --user=user_name --password=your_password db_name;

Type;,/GOr/GPress enter to execute the statement.

You can also execute a script file Statement as follows:

shell> mysql db_name < script.sql > output.tab
On Unix systems, MysqlThe client writes execution statement records to history files.

 

Mysqladmin

Mysqladmin performs administrative operations on the client. You can use this command to check the service configuration and current status, and create and delete databases. As follows:

shell> mysqladmin [options] command [command-arg] [command [command-arg]] ...

 

Mysqlcheck

MysqlcheckExecute table maintenance: check, repair, optimize, or analyze.

When you execute this command, the table is locked (read-only), so it is unavailable for other sessions. Table maintenance is time-consuming, especially for large tables. If you use-- DatabasesOr-- All-databasesTo process all tables of one or more databases,MysqlcheckIt may take a long time.

MysqlcheckAndMyisamchk, But the running is different. The main difference is that,MysqlcheckOnly whenMysqldServices can be used only when running, whileMyisamchkNo. UseMysqlcheckThe benefit is that you can perform table maintenance without stopping the service.

MysqlcheckUse SQL statements in a convenient wayCHECK TABLE,REPAIR TABLE,ANALYZE TABLEAndOPTIMIZE TABLE. Determine which statement you want to execute, and then send it to the server for execution.

MyISAMThe storage engine supports all four maintenance operations. therefore,MysqlcheckIt can be used inMyISAMExecute any one on the table. Other storage engines cannot be fully supported. The error message is displayed. For example, ifTest. tIsMEMORYTable, check will produce the following results:

shell> mysqlcheck test t
test.t
note : The storage engine for the table doesn't support check

CallMysqlcheckGenerally, there are three methods:

shell> mysqlcheck [options] db_name [tbl_name ...]
shell> mysqlcheck [options] --databases db_name ...
shell> mysqlcheck [options] --all-databases

IfDb_nameSpecify any table name or use-- DatabasesOr-- All-databasesCheck the entire database.

Compared with other client programs,MysqlcheckHas a special feature. You can rename it as binary to change the default behavior of the checklist. If you want to have a tool to fix tables by default, you only need to copyMysqlcheckAnd rename itMysqlrepair, Or use symbols to connect. If mysqlrepair is called, it will repair the table.

 

Mysqldump

MysqldumpIt was originally a backup program written by Igor Romanenko. To dump a database or database set for backup, it is transmitted to another SQL service (not the MySQL service ). Dump typically contains SQL statements for creating tables, filling tables, or both.MysqldumpIt is also used to generate CSV files, other separated text, or XML format.

Dump the MySQL database to a client program (such as an SQL statement or a tab separator text file.

MysqldumpRequires at leastSELECTPermission (used to dump tables ),SHOW VIEWPermissions (used to dump views), andLOCK TABLESPermission (if not used-- Single-transactionOption ).

If the data is backed up, but all tables areMyISAMTable, you can considerMysqlhotcopyBecause it can complete backup and recovery faster.

There are three methods to call mysqldump:

shell> mysqldump [options] db_name [tbl_name ...]
shell> mysqldump [options] --databases db_name ...
shell> mysqldump [options] --all-databases

IfDb_nameSpecify any table name or use-- DatabasesOr-- All-databasesOption, the entire database will be dump.

By default,MysqldumpNot dumpINFORMATION_SCHEMADatabase. However, it can be explicitly specified in the command line. Before MySQL 5.5,MysqldumpIgnoredINFORMATION_SCHEMADatabase, even if you explicitly specify in the command line.

MysqldumpNot dumpPerformance_schemaDatabase.

MySQL versions earlier than 5.25,MysqldumpNot dumpGeneral_logOrSlow_query_logTable. The MySQL 5.5.25 dump contains statements for recreating these tables so that they will not be lost after the dump file is reloaded. The contents of the log table are not dumped.

MysqldumpIt will not dump the MySQL Cluster ndbinfo information database.

MysqldumpOption list, please execute"Mysqldump -- help".

 

Mysqlimport

Mysqlimport isLOAD DATA INFILEAn SQL statement provides a command line interface. As follows:

shell> mysqlimport [options] db_name textfile1 [textfile2 ...]

Each textfile specified on the command line,MysqlimportRemove the extension from the file name, use the result to determine the table name, and import it to the file content. For example, if the names are patient.txt and patient. text, all patient files will be imported to a table named patient.

 

Mysqlshow

MysqlshowUsed to quickly view existing databases, tables, columns, or indexes.

Mysqlshow is a lot of SQLSHOWThe statement provides a command line interface. As follows:

shell> mysqlshow [options] [db_name [tbl_name [col_name]]]
  • If no database is specified, all databases are displayed.
  • If no table is specified, all tables in the database are displayed.
  • If no column is specified, all columns and types of the table are displayed.

You can use wildcards (*,? , % ,_).

 

Mysqlslap

Mysqlslap is a diagnostic program used to simulate client loading and report the time of each phase. This command is useful if multiple clients are accessing the service. As follows:

shell> mysqlslap [options]

 

References
  • MySQL dev http://dev.mysql.com/doc/

BitsCN.com

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.