在[mysqld]下配置log-error,在启动错误日志。如果需要指定文件名,则配置项如下:
?
[mysqld] log-error=[path/[file_name]]path为日志文件所在的目录路径,filename为日志文件名。修改配置项后,需要重启mysql服务才生效
?
2、查看错误日志
通过错误日志可以监视系统的运行状态,便于及时发现故障,修复故障。mysql错误日志是以文本文件形式存储的,可以使用文本编辑器直接查看mysql错误日志
如果不知道日志文件的存储路径,可以使用 show variables; 语句查看错误日志的存储路径。
语句如下
show variables LIKE 'log_error';

使用记事本查看mysql错误日志
通过上面 show variables LIKE'log_error'; 的语句查看到错误日志的路径,然后用记事本打开该文件
我们可以看到错误日志内容如下
140705 16:41:17 [Note] Plugin 'FEDERATED' is disabled. 140705 16:41:17 InnoDB: The InnoDB memory heap is disabled 140705 16:41:17 InnoDB: Mutexes and rw_locks use Windows interlocked functions 140705 16:41:17 InnoDB: Compressed tables use zlib 1.2.3 140705 16:41:17 InnoDB: Initializing buffer pool, size = 2.0G 140705 16:41:18 InnoDB: Completed initialization of buffer pool InnoDB: The first specified data file E:\MYSQL DataBase\ibdata1 did not exist: InnoDB: a new database to be created! 140705 16:41:18 InnoDB: Setting file E:\MYSQL DataBase\ibdata1 size to 10 MB InnoDB: Database physically writes the file full: wait... 140705 16:41:18 InnoDB: Log file .\ib_logfile0 did not exist: new to be created InnoDB: Setting log file .\ib_logfile0 size to 213 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 200 140705 16:41:21 InnoDB: Log file .\ib_logfile1 did not exist: new to be created InnoDB: Setting log file .\ib_logfile1 size to 213 MB InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 200 InnoDB: Doublewrite buffer not found: creating new InnoDB: Doublewrite buffer created InnoDB: 127 rollback segment(s) active. InnoDB: Creating foreign key constraint system tables InnoDB: Foreign key constraint system tables created 140705 16:41:23 InnoDB: Waiting for the background threads to start 140705 16:41:24 InnoDB: 1.1.8 started; log sequence number 0 140705 16:41:24 [Note] Event Scheduler: Loaded 0 events 140705 16:41:24 [Note] E:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld: ready for connections. Version: '5.5.19' socket: '' port: 3306 MySQL Community Server (GPL) 140705 23:44:14 [Note] E:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld: Normal shutdown 140705 23:44:14 [Note] Event Scheduler: Purging the queue. 0 events 140705 23:44:14 InnoDB: Starting shutdown... 140705 23:44:15 InnoDB: Shutdown completed; log sequence number 1595675 140705 23:44:15 [Note] E:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld: Shutdown complete 140706 8:17:09 [Note] Plugin 'FEDERATED' is disabled. 140706 8:17:09 InnoDB: The InnoDB memory heap is disabled 140706 8:17:09 InnoDB: Mutexes and rw_locks use Windows interlocked functions 140706 8:17:09 InnoDB: Compressed tables use zlib 1.2.3 140706 8:17:09 InnoDB: Initializing buffer pool, size = 2.0G 140706 8:17:10 InnoDB: Completed initialization of buffer pool 140706 8:17:10 InnoDB: highest supported file format is Barracuda. 140706 8:17:14 InnoDB: Waiting for the background threads to start 140706 8:17:15 InnoDB: 1.1.8 started; log sequence number 1595675 140706 8:17:16 [Note] Event Scheduler: Loaded 0 events 140706 8:17:16 [Note] E:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld: ready for connections. Version: '5.5.19' socket: '' port: 3306 MySQL Community Server (GPL) 140706 14:05:35 [Note] E:\Program Files\MySQL\MySQL