This article mainly shares some common Mysql errors and solutions. For more information, see
1. problem: mysql DNS reverse solution: skip-name-resolve
The error log has a similar warning:
1.120119 16:26:04 [Warning] IP address '192. 168.1.10 'cocould not be resolved: Name or service not known
2.120119 16:26:04 [Warning] IP address '192. 168.1.14 'cocould not be resolved: Name or service not known
3.120119 16:26:04 [Warning] IP address '192. 168.1.17 'cocould not be resolved: Name or service not known
A large number of connections similar to the following are found through show processlist:
1. | 592 | unauthenticated user | 192.168.1.10: 35320 | NULL | Connect | login | NULL |
2. | 593 | unauthenticated user | 192.168.1.14: 35321 | NULL | Connect | login | NULL |
3. | 594 | unauthenticated user | 192.168.1.17: 35322 | NULL | Connect | login | NULL |
The function of the skip-name-resolve parameter is as follows: no reverse resolution is performed (the ip address is not resolved as a domain name), which can speed up the response time of the database.
Modify the configuration file and restart it:
[Mysqld]
Skip-name-resolve
2. Error log: Error: Can't create a new thread (errno 12)
Due to database server problems, a new thread cannot be created for database operations. Generally, there are three reasons:
1) MySQL threads are too open.
2) the server system memory overflows.
3) Environmental Software damage or system damage.
[Problem solving]
1.1) enter the user table in the mysql database of phpmyadmin, edit the database user, and modify the value of max_connections. Change it to a smaller value.
2.2) contact the server administrator to check whether the server memory and system are normal. if the server memory is insufficient, check which processes consume the server memory, at the same time, consider whether to increase the server memory to improve the load capacity of the entire system.
3.3) mysql version changed to stable version
4.4) optimize the SQL of website programs, etc.
3. operation ERROR: Error 1010 (HY000): ERROR dropping database
1. mysql> drop database xjtrace;
2. ERROR 1010 (HY000): Error dropping database (can't rmdir './xjtrace/
This prompt appears when you delete a database. The reason is that the database contains files that you put in, for example *. txt file or *. SQL file, etc., as long as the file is deleted and executed.
1. mysql> drop database xjtrace;
2. Query OK, 0 rows affected (0.00 sec)
Delete it !!
4. export data quickly, but import data to the new database is slow:
The SQL statement exported from MySQL may be very slow during import. it took nearly two hours to import only 4 million records. Using a few parameters properly during export can greatly speed up the import.
-E uses the multiline INSERT syntax that includes several VALUES lists;
-- Max_allowed_packet = maximum size of the cache for communications between the XXX client/server;
-- Net_buffer_length = XXX TCP/IP and socket communication buffer size, create line with length up to net_buffer_length
Note: max_allowed_packet and net_buffer_length cannot be greater than the configuration value of the target database. Otherwise, an error may occur.
First, determine the parameter value of the target database.
Mysql> show variables like 'max _ allowed_packet ';
+ -------------------- + --------- +
| Variable_name | Value |
+ -------------------- + --------- +
| Max_allowed_packet| 1048576 |
+ -------------------- + --------- +
1 row in set (0.00 sec)
Mysql> show variables like 'net _ buffer_length ';
+ ----------------- + ------- +
| Variable_name | Value |
+ ----------------- + ------- +
| Net_buffer_length | 16384 |
+ ----------------- + ------- +
1 row in set (0.00 sec)
Write the mysqldump command based on the parameter value, for example:
Mysql> mysqldump-uroot-p database name-e -- max_allowed_packet = 1048576-net_buffer_length = 16384> SQL file
For example:
1. mysql> mysqldump-uroot-p xjtrace-e -- max_allowed_packet = 1048576 -- net_buffer_length = 16384> xjtrace_data _ 'date + % f'. SQL
The SQL statements that can be imported in the past two hours can be completed in dozens of seconds.