Unable to find all executed mysql commands in history file ( .mysql_history )
Hi,
I am newbie in mysql.
I have one question regarding mysql saving commands in the history file ~/.mysql_history.
I have read the mysql documentation regarding usage of this file but I didn't found the answer ( MySQL 5.5 Reference Manual / MySQL Programs / MySQL Client Programs / mysql — The MySQL Command-Line Tool / mysql Logging ):
I am using the linux test server with:
- OS is the Red Hat Enterprise Linux Server release 5.6 (Tikanga)
- mysql Server version: 5.5.37 MySQL Community Server
This is the scenario (based on two connection windows):
- first connection window>
[root@maximus ~]# mysql -u comodus -p************ -h 192.168.155.100
mysql> CREATE TABLE Persons7
-> (
-> Id int NOT NULL UNIQUE,
-> LastName varchar(255) NOT NULL,
-> FirstName varchar(255),
-> Address varchar(255),
-> City varchar(255)
-> )
-> ;
Query OK, 0 rows affected (0.01 sec)
- second connection window>
[root@maximus ~]# mysql -u comodus -p************ -h 192.168.155.100
mysql> CREATE TABLE Persons8
-> (
-> Id int NOT NULL UNIQUE,
-> LastName varchar(255) NOT NULL,
-> FirstName varchar(255),
-> Address varchar(255),
-> City varchar(255)
-> )
-> ;
Query OK, 0 rows affected (0.00 sec)
- first connection window (close connection)>
mysql> exit
Bye
After that I can see the content of file .mysql_history in home of root directory:
CREATE TABLE Persons7
(
Id int NOT NULL UNIQUE,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)
;
CREATE TABLE Persons7 ( Id int NOT NULL UNIQUE, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255) );
- second connection window (close connection)>
mysql> exit
Bye
After that I can see the content of file .mysql_history in home of root directory:
CREATE TABLE Persons8
(
Id int NOT NULL UNIQUE,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)
;
CREATE TABLE Persons8 ( Id int NOT NULL UNIQUE, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255) );
I am not sure what is happened, but I don't see anymore first CREATE TABLE Persons7 ddl in mysql history file.
It's look like second create stmt has moved first create stmt.
I have tried to restart mysql server:
[root@maximus ~]# /etc/init.d/mysql restart
Also I have restarted the test server:
shutdown -r now
After that I have the same situation, regarding mysql history file content.
Is this regular behavior of mysql, or I have made some mistake?
Thanks,
Regards