|
Home >> FAQs/Tutorials >> MySQL Tutorials
MySQL FAQs - Server Daemon mysqld Administration
By: FYIcenter.com
Part:
1
2
3
4
(Continued from previous part...)
How To Turn on Query Logs?
If you want MySQL to write query logs to a file, you can use the "--log=fileName" option
at the "mysqld" command line. The tutorial exercise below shows you a good example
on how to use this option and view the query log file:
>cd \mysql\bin
>mkdir \mysql\logs
>mysqld --log=\mysql\logs\query.log
Starts another command window, and enter the following commands:
>cd \mysql\bin
>mysql -u root -pretneciyf
mysql> USE test;
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| articles |
| links |
| test |
+----------------+
3 rows in set (0.03 sec)
mysql> SELECT * FROM links;
+------+-------------------+
| id | name |
+------+-------------------+
| 1 | dba.fyicenter.com |
| 10 | dba.fyicenter.com |
+------+-------------------+
2 rows in set (0.11 sec)
mysql> EXIT;
Bye
Here is what you will get in the query log file:
>type \mysql\logs\query.log
mysqld, Version: 5.0.24-community-log. started with:
Tcp port: 0 Unix socket: (null)
Time Id Command Argument
20:19:41 3 Connect root@localhost on
20:20:00 3 Query SELECT DATABASE()
3 Init DB test
20:20:05 3 Query show tables
20:20:52 3 Query SELECT * FROM links
20:21:02 3 Quit
How To Turn on Error Logs?
If you want MySQL to write critical errors into a log file,
you can use the "--log-error=fileName" option at the "mysqld" command line.
The tutorial exercise below shows you a good example
on how to use this option:
>cd \mysql\bin
>mkdir \mysql\logs
>mysqld --log-error=\mysql\logs\error.log
If there is critical errors, your error log will be pretty empty:
>type \mysql\logs\error.log
20:32:21 InnoDB: Started; log sequence number 0 43665
20:32:21 [Note] mysqld: ready for connections.
Version: '5.0.24-community-log' socket: '' port: 3306
What Is Binary Log File?
MySQL server binary log file plays an important role in restoring database changes
to the server. Main features on binary log files are:
- Binary logs can be turned on by "--log-bin=fileBaseName" option on "mysqld".
- Binary logs only records statements that are changing data in the database.
So a simple SELECT statement will be not recorded in binary logs.
- Binary logs are organized in multiple files with names like: base.index, base.000001,
base.000002, etc. Each time when you restart the server, a new binary log file will be created.
- Binary log files can be viewed by "mysqlbinlog" program.
- Binary log files can be piped into back to the server as
"mysqlbinlog base.000001 | mysql" for restoring data changes after a server crash.
(Continued on next part...)
Part:
1
2
3
4
|