通过程序脚本的日志跟踪,主要报错信息为“MySQL server has gone away”。官方的解释是:
The most common reason for the MySQL server has gone away error is that the server timed out and closed the connection.
Some other common reasons for the MySQL server has gone away error are:
You (or the db administrator) has killed the running thread with a KILL statement or a mysqladmin kill command.
You tried to run a query after closing the connection to the server. This indicates a logic error in the application that should be corrected.
A client application running on a different host does not have the necessary privileges to connect to the MySQL server from that host.
You got a timeout from the TCP/IP connection on the client side. This may happen if you have been using the commands: mysql_options(..., MYSQL_OPT_READ_TIMEOUT,...) or mysql_options(..., MYSQL_OPT_WRITE_TIMEOUT,...). In this case increasing the timeout may help solve the problem.
You have encountered a timeout on the server side and the automatic reconnection in the client is disabled (the reconnect flag in the MYSQL structure is equal to 0).
You are using a Windows client and the server had dropped the connection (probably because wait_timeout expired) before the command was issued.
The problem on Windows is that in some cases MySQL doesn't get an error from the OS when writing to the TCP/IP connection to the server, but instead gets the error when trying to read the answer from the connection.
In this case, even if the reconnect flag in the MYSQL structure is equal to 1, MySQL does not automatically reconnect and re-issue the query as it doesn't know if the server did get the original query or not.
The solution to this is to either do a mysql_ping on the connection if there has been a long time since the last query (this is what MyODBC does) or set wait_timeout on the mysqld server so high that it in practice never times out.
You can also get these errors if you send a query to the server that is incorrect or too large. If mysqld receives a packet that is too large or out of order, it assumes that something has gone wrong with the client and closes the connection. If you need big queries (for example, if you are working with big BLOB columns), you can increase the query limit by setting the server's max_allowed_packet variable, which has a default value of 1MB. You may also need to increase the maximum packet size on the client end. More information on setting the packet size is given in Section A.1.2.9, “Packet too large”.
An INSERT or REPLACE statement that inserts a great many rows can also cause these sorts of errors. Either one of these statements sends a single request to the server irrespective of the number of rows to be inserted; thus, you can often avoid the error by reducing the number of rows sent per INSERT or REPLACE.
You also get a lost connection if you are sending a packet 16MB or larger if your client is older than 4.0.8 and your server is 4.0.8 and above, or the other way around.
It is also possible to see this error if hostname lookups fail (for example, if the DNS server on which your server or network relies goes down). This is because MySQL is dependent on the host system for name resolution, but has no way of knowing whether it is working — from MySQL's point of view the problem is indistinguishable from any other network timeout.
You may also see the MySQL server has gone away error if MySQL is started with the --skip-networking option.
Another networking issue that can cause this error occurs if the MySQL port (default 3306) is blocked by your firewall, thus preventing any connections at all to the MySQL server.
You can also encounter this error with applications that fork child processes, all of which try to use the same connection to the MySQL server. This can be avoided by using a separate connection for each child process.
You have encountered a bug where the server died while executing the query.
这段代码的含义,与Mysql官方建议的方法思路相符[ If you have a script, you just have to issue the query again for the client to do an automatic reconnection. ]。在实际分析中发现,if(!$conn)并不是可靠的,程序通过了if(!$conn)的检验后,仍然会返回上述错误。
070315 13:36:35 [ERROR] mysql.user has no `Event_priv` column at position 29 070315 13:36:35 [ERROR] SCHEDULER: The system tables are damaged. The scheduler subsystem will be unusable during this run.
下面以Red Hat Linux 9为平台,说明在Apache 2.0中如何指定MPM (Apache采用2.0.45)。先解压缩源代码包httpd-2.0.45.tar.gz,生成httpd-2.0.45目录(Apache 1.3源代码包的命名规则是apache_1.3.NN.tar.gz,而2.0版则是httpd-2.0.NN.tar.gz,其中NN是次版本号)。
进入httpd-2.0.45目录,运行以下代码:
$ ./configure --help|grep mpm
显示如下:
--with-mpm=MPM Choose the process model for Apache to use. MPM={beos|worker|prefork|mpmt_os2| perchild|leader|threadpool}
CREATE TABLE tr (id INT, name VARCHAR(50), purchased DATE) PARTITION BY RANGE(YEAR(purchased)) ( PARTITION p0 VALUES LESS THAN (1990), PARTITION p1 VALUES LESS THAN (1995), PARTITION p2 VALUES LESS THAN (2000), PARTITION p3 VALUES LESS THAN (2005) );
10.10.82.83 [testuser]$ l total 404M -rw-rw---- 1 mysql mysql 8.5K 2007-03-14 15:26:29 tr.frm -rw-rw---- 1 mysql mysql 32 2007-03-14 15:26:29 tr.par -rw-rw---- 1 mysql mysql 68 2007-03-14 15:26:48 tr#P#p0.MYD -rw-rw---- 1 mysql mysql 1.0K 2007-03-14 15:26:48 tr#P#p0.MYI -rw-rw---- 1 mysql mysql 48 2007-03-14 15:26:48 tr#P#p1.MYD -rw-rw---- 1 mysql mysql 1.0K 2007-03-14 15:26:48 tr#P#p1.MYI -rw-rw---- 1 mysql mysql 44 2007-03-14 15:26:48 tr#P#p2.MYD -rw-rw---- 1 mysql mysql 1.0K 2007-03-14 15:26:48 tr#P#p2.MYI -rw-rw---- 1 mysql mysql 84 2007-03-14 15:26:48 tr#P#p3.MYD -rw-rw---- 1 mysql mysql 1.0K 2007-03-14 15:26:48 tr#P#p3.MYI
说明创建分区成功。
测试分区管理,删除:
ALTER TABLE tr DROP PARTITION p2;
添加:
ALTER TABLE tr ADD PARTITION (PARTITION p2 VALUES LESS THAN (2000));
去年看了不少关于体育的影片,《Remember The Titans》、《Glory Road》、《Invincible》、《Gridiron Gang》、《Facing The Giants》,有很多感触,真的很想能够跟团队在一起观看一起分享影片中那种团队获得成功的感动。在向共同目标努力的过程中,大家一起克服困难,互相帮助,团队的精神才会深入每个人的内心,感召和改变着每一个人。
例子: CREATE TRIGGER update_customer_address UPDATE OF address ON customers BEGIN UPDATE orders SET address = new.address WHERE customer_name = old.name; END; 说明:创建了一个名为update_customer_address的触发器,当用户更新customers表中的address字段时,将触发并更新orders表中的address字段为新的值。 比如执行如下一条语句:UPDATE customers SET address = '1 Main St.' WHERE name = 'Jack Jones'; 数据库将自动执行如下语句: UPDATE orders SET address = '1 Main St.' WHERE customer_name = 'Jack Jones';
CREATE INDEX
为给定表或视图创建索引。
语法:
sql-statement ::=
CREATE [UNIQUE] INDEX index-name ON [database-name .]table-name ( column-name[, column-name]* )[ ON CONFLICT conflict-algorithm]
column-name ::=
name[ COLLATE collation-name][ ASC | DESC ]
例子:CREATE INDEX idx_email ON customers (email); 说明: 为customers表中的email创建一个名为idx_email的字段。
结构删除
DROP TABLE
删除表定义及该表的所有索引。
语法:
sql-command ::=
DROP TABLE [database-name.]table-name
例子: DROP TABLE customers;
DROP VIEW
删除一个视图。
语法:
sql-command ::=
DROP VIEW view-name
例子: DROP VIEW master_view;
DROP TRIGGER
删除一个触发器。
语法:
sql-statement ::=
DROP TRIGGER [database-name .]trigger-name
例子:DROP TRIGGER update_customer_address;
DROP INDEX
删除一个索引。
语法:
sql-command ::=
DROP INDEX [database-name .]index-name
例子:DROP INDEX idx_email;
数据操作
INSERT
将新行插入到表。
语法:
sql-statement ::=
INSERT [OR conflict-algorithm] INTO [database-name .]table-name[(column-list)] VALUES(value-list) | INSERT [OR conflict-algorithm] INTO [database-name .]table-name[(column-list)]select-statement
UPDATE
更新表中的现有数据。
语法:
sql-statement ::=
UPDATE [ OR conflict-algorithm][database-name .]table-name SET assignment[, assignment]*[WHERE expr]
assignment ::=
column-name = expr
DELETE
从表中删除行。
语法:
sql-statement ::=
DELETE FROM [database-name .]table-name[WHERE expr]
SELECT
从表中检索数据。
语法:
sql-statement ::=
SELECT [ALL | DISTINCT]result[FROM table-list][WHERE expr][GROUP BY expr-list][HAVING expr][compound-opselect]*[ORDER BY sort-expr-list][LIMIT integer<