How to View and import and export MySQL logs in Windows _ MySQL

Source: Internet
Author: User
Tags mysql create mysql create database mysql import
This article describes how to view and import and export MySQL logs in Windows, if you need it, you can refer to MYSQL with different types of log files (each storing different types of logs), from which you can find out what MYSQL has done, these log files are indispensable for MYSQL management.
1. The error log records The error information during database startup, operation, and stop;
2. ISAM operation log (The isam log): records all changes to The ISAM table. This log is only used to debug The ISAM mode;
3. SQL execution log (The query log): records The client connection and The executed SQL statements;
4. update log: The statement that records data changes. it is not recommended to use this log instead of binary logs;
5. binary log: records all statements for modifying database data;
6. The time-out log (The slow log): records all statements whose execution time exceeds The maximum SQL execution time (long_query_time) or where no index is used;

If you are using mysql's copy and backup functions, the slave 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 re-open a file to record the logs. of course, the system will automatically add a suffix (such. 00001 ,. 00002). you can run the mysql> flush logs statement in the mysql environment or run the mysqladmin management program # mysqladmin flush-logs or # mysqladmin refresh.

The startup method of these logs can be followed by the option parameters when the mysqld_safe method is used to start the database, or configured in the configuration file. The second method is recommended. the configuration method is very simple, I only configured three types of logs:

[mysqld]log=/var/log/mysqld_common.loglog-error=/var/log/mysqld_err.loglog-bin=/var/log/mysqld_bin.bin

View
Log viewing is very simple. most of the logs are text. you can directly view the logs using tools such as vim, less, and more. it is worth noting that you can view the binary files:

1) First, determine whether the binary file record function is enabled.

mysql>show variables like 'log_bin';

2) If you want to know the details of the file that records binary data, you can use the following statement to see which file is being recorded and the current location of the record:

mysql>show master status;

3) to view binary data, you need to use the program mysqlbinlog to see which options are supported and use them as needed.

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

You can execute the following statements to query a certain time range. if there are many records, you can direct the results to a file and read them :-):

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
There are many types of MySQL database export. now I will introduce the MySQL mysqldump command export and import.
Note: During export, the data is exported according to the mysql table encoding. If the encoding on the mysql server is inconsistent with the table during import, an error occurs during import.
1. MySQL export the entire database table structure and data commands:

Mysqldump-u username-p password dbName> f: \ path + export SQL name

Note: The. SQL file is generated, but multiple databases are generated. multiple databases are separated by commas.
2. MySQL export the structure and data commands of a single table in the database:

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 command for exporting the entire database table structure:

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

Note: the entire database table structure generates a. SQL file.
4. commands for exporting a single table structure from MySQL:

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

Note: a single table structure generates a. SQL file, but multiple tables. Multiple tables are distinguished by spaces.

Import
MySQL import:
1) go to cmd
2)

Mysql-h localhost-u username-p password

3)

Mysql-h-localhost-u username-p password to enter mysql create database test use test source f: \ test. SQL

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.