Monday, December 24, 2012

Last_Errno: 1007: Error 'can’t create database 'databasename'; database exists' on query. Default database: 'databasename'. Query: 'create database databasename'



1         Check below entry in slave server:
            mysql> show slave status\G;
Master_Log_File: mysql-bin.000006
            Read_Master_Log_Pos: 231202
                        Relay_Log_File: mysqld-relay-bin.000004
                        Relay_Log_Pos: 503
            Relay_Master_Log_File: mysql-bin.000003
           Slave_IO_Running: Yes
            Slave_SQL_Running: No
           
Note: 
a)      Both Master_Log_File and Relay_Master_Log_File must be same.
b)      Both Slave_IO_Running and Slave_SQL_Running must be yes.

2          Check file name and bin log position on master server:
mysql> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000006 |   231202 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

3.         Stop the slave server:
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)

4.         Change master log file name and log position
mysql> CHANGE MASTER TO MASTER_HOST='xxxxx.xxx.xx',MASTER_USER='master_user',MASTER_PASSWORD='master_user_password',MASTER_LOG_FILE='mysql-bin.000006',MASTER_LOG_POS=202;
Query OK, 0 rows affected (0.05 sec)

5.         Start Slave Server:
mysql> start slave ;
Query OK, 0 rows affected (0.01 sec)

6.         Check slave server status:
mysql> show slave status\G;
           Master_Log_File: mysql-bin.000006
            Read_Master_Log_Pos: 231202
                        Relay_Log_File: mysqld-relay-bin.000002
                        Relay_Log_Pos: 235
            Relay_Master_Log_File: mysql-bin.000006
            Slave_IO_Running: Yes
            Slave_SQL_Running: Yes