Windows Mysql Log Basic view and Import Export usage tutorial _mysql

Source: Internet
Author: User
Tags datetime flush one table create database mysql export database mysql import

MySQL has different types of log files (each store a different type of log), from which you can query what is done in MySQL, for the management of MySQL, these log files are indispensable.
1. Error log: Log the database startup, operation and stop process error messages;
2.ISAM operation log (the ISAM log): All modifications to the ISAM table are recorded, which are used only for debugging ISAM mode;
3.SQL execution log (the query log): Logs the client's connection and the executed SQL statement;
4. Update log: Record the statement that changes the data, has not been recommended to use, replaced by binary log;
5. Binary log (the binary log): All modifications to the database data are recorded;
6. Timeout log: Records all statements with execution times exceeding the maximum SQL execution time (long_query_time) or unused index (slow);

If you are using MySQL copy, backup function, then from the server also provides a log file called Relay log.

By default, all log files are recorded in the MySQL data directory, you can force MySQL to close and reopen a file for logging, of course, the system will automatically add suffixes (such as. 00001,. 00002), in the form of a MySQL environment to execute the statement mysql> Flush logs; or perform #mysqladmin flush-logs or #mysqladmin refresh via the Mysqladmin management program

These logs can be started in a mysqld_safe way to start the database, followed by option parameters, can also be configured in the configuration file, recommended a second way, the configuration method is very simple, I only configured three kinds of logs:

[Mysqld]
Log=/var/log/mysqld_common.log
log-error=/var/log/mysqld_err.log
log-bin=/var/log/mysqld_bin.bin

View
Log view is very simple, most of them are text, directly with Vim, less, more and other tools to see it, it is worth noting that the binary file view:

1. First determine if the binary file logging function is turned on

Mysql>show variables like ' log_bin ';

2. If you want to know the file details of the binary data now recorded, you can see in the following statement which file is being logged, and the current location of the record:
Mysql>show Master status;

3. Viewing binary data requires a program Mysqlbinlog to see what options it supports, depending on what you want to use.

mysql>mysqlbinlog/var/log/mysql/mysql-bin.000040;

Query for a certain time range can execute the following statements, if a lot of records can be directed to a file to take a slow look at:-) :

Mysql>mysqlbinlog--start-datetime= ' 2008-01-01 00:00:00 '--stop-datetime= ' 2008-08-08 00:00:00 '/var/log/mysql/ mysql-bin.000040 >/tmp.log

Export
MySQL Database export There are many kinds of, I now introduce MySQL with the mysqldump command export import.
Note: When exporting, export according to the MySQL table code. If the MySQL server-side encoding does not match the table when importing, an import error occurs.
1, MySQL export the entire database table structure and data command:

Mysqldump-u Username-p password dbname>f:\ path + export SQL name 

Note: the. sql file is generated, but it is multiple databases and multiple databases are separated by commas.
2. mysql Export database single table table structure and data command:

Mysqldump-u User name-p password database name table name >f:\ path + export SQL name 

Note: Multiple tables can be separated by commas.
3, MySQL export the entire database table structure command:

Mysqldump-u User name-p password-d database name >f:\ path + export SQL name 

Note: The entire database table structure generates. sql files.
4. mysql Export database single table structure command:

Mysqldump-u User name-p password-d database Name Table name >f:\ path + export SQL name 

Note: A single table structure that generates. sql files, but more than one table. Multiple tables are separated by spaces

Import
MySQL Import:
1) Enter CMD
2)

Mysql-h localhost-u user name-p password 

3)

Mysql-h-localhost-u user name-p password into MySQL 
create database test use 
test 
source F:\test.sql 

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.