MYSQL Post Installation - configuration change
What to tune in MySQL Server after installation
Friday, July 09, 2010
Monday, April 26, 2010
Replication - Relay log corrupt
My replication stop
Check with
show slave status\G
Last_Error :Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.
Check error log
100420 20:28:02 [ERROR] Error running query, slave SQL thread aborted.
Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000078' position 1112628
100420 21:26:58 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.000078' at position 1112628, relay log '/usr/local/mysql/relay-bin/relay.000714' position: 002082
100420 21:27:00 [ERROR] Error in Log_event::read_log_event(): 'read error', data_len: 7195, event_type: 16
100420 21:27:00 [ERROR] Error reading relay log event: slave SQL thread aborted because of I/O error
100420 21:27:00 [ERROR] Slave: Could not parse relay log event entry. The possible reasons are:
the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log),
the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log),
a network problem, or a bug in the master's or slave's MySQL code.
If you want to check the master's binary log or slave's relay log,
you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.
Error_code: 0
check relay log '/usr/local/mysql/relay-bin/relay.000714'
log disappear. lateset one is relay.000722
Reset relay log
Check the below information with
show slave status\G
Relay_Master_Log_File: mysql-bin.000078
Exec_Master_Log_Pos: 1996668
The command should be as below
CHANGE master TO master_log_file=Relay_Master_Log_File,master_log_pos=Exec_Master_Log_Pos
So I run this
CHANGE master TO master_log_file=mysql-bin.000078,master_log_pos=1996668
The relay_log in /usr/local/mysql/relay-bin want delete, and new relay log is populate
MYSQL Replication is resume
The above solution work fine for my server
Reference :
http://sql.dzone.com/news/troubleshooting-relay-log-corr
http://www.mysqlperformanceblog.com/2008/08/02/troubleshooting-relay-log-corruption-in-mysql/
Check with
show slave status\G
Last_Error :Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.
Check error log
100420 20:28:02 [ERROR] Error running query, slave SQL thread aborted.
Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000078' position 1112628
100420 21:26:58 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.000078' at position 1112628, relay log '/usr/local/mysql/relay-bin/relay.000714' position: 002082
100420 21:27:00 [ERROR] Error in Log_event::read_log_event(): 'read error', data_len: 7195, event_type: 16
100420 21:27:00 [ERROR] Error reading relay log event: slave SQL thread aborted because of I/O error
100420 21:27:00 [ERROR] Slave: Could not parse relay log event entry. The possible reasons are:
the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log),
the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log),
a network problem, or a bug in the master's or slave's MySQL code.
If you want to check the master's binary log or slave's relay log,
you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave.
Error_code: 0
check relay log '/usr/local/mysql/relay-bin/relay.000714'
log disappear. lateset one is relay.000722
Reset relay log
Check the below information with
show slave status\G
Relay_Master_Log_File: mysql-bin.000078
Exec_Master_Log_Pos: 1996668
The command should be as below
CHANGE master TO master_log_file=Relay_Master_Log_File,master_log_pos=Exec_Master_Log_Pos
So I run this
CHANGE master TO master_log_file=mysql-bin.000078,master_log_pos=1996668
The relay_log in /usr/local/mysql/relay-bin want delete, and new relay log is populate
MYSQL Replication is resume
The above solution work fine for my server
Reference :
http://sql.dzone.com/news/troubleshooting-relay-log-corr
http://www.mysqlperformanceblog.com/2008/08/02/troubleshooting-relay-log-corruption-in-mysql/
Sunday, April 18, 2010
Grant permission - Checking
If we want to know what permissions have grant to the user,
we can use the below command :
mysql>show grants for 'root';
Grants for Root@%
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION
Reference :
http://dev.mysql.com/doc/refman/4.1/en/show-grants.html
if we want to know what user been grant to table, we can use the below method
mysql> select * mysql.tables_priv where table_name='mytable';
+------+--------+---------------+---------------------+----------------+---------------------+---------------+-------------+
| Host | Db | User | Table_name | Grantor | Timestamp | Table_priv | Column_priv |
+------+--------+---------------+---------------------+----------------+---------------------+---------------+-------------+
| % | testdb | test_user | mytable | root@127.0.0.1 | 2009-01-08 18:38:14 | Select,Delete | |
| % | testdb | test_user2 | mytable | | 2010-03-23 16:09:00 | Select | |
+------+--------+---------------+---------------------+----------------+---------------------+---------------+-------------+
we can use the below command :
mysql>show grants for 'root';
Grants for Root@%
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION
Reference :
http://dev.mysql.com/doc/refman/4.1/en/show-grants.html
if we want to know what user been grant to table, we can use the below method
mysql> select * mysql.tables_priv where table_name='mytable';
+------+--------+---------------+---------------------+----------------+---------------------+---------------+-------------+
| Host | Db | User | Table_name | Grantor | Timestamp | Table_priv | Column_priv |
+------+--------+---------------+---------------------+----------------+---------------------+---------------+-------------+
| % | testdb | test_user | mytable | root@127.0.0.1 | 2009-01-08 18:38:14 | Select,Delete | |
| % | testdb | test_user2 | mytable | | 2010-03-23 16:09:00 | Select | |
+------+--------+---------------+---------------------+----------------+---------------------+---------------+-------------+
Wednesday, March 03, 2010
Innodb table can't create
I want to recreate mysql database
- Stop mysql server, delete all data file and
- Recreate mysql database
sudo scripts/mysql_install_db --user=mysql --datadir=/data
- Restart mysql database
sudo bin/mysqld_safe --user=mysql --default-character-set=utf8
- The ibdata1, ibdata2 recreate and mysql start
- I create table in innodb, but table appear in myisam
CREATE TABLE `staff` (
`staff_id` int(10) unsigned NOT NULL auto_increment,
`staff_name` varchar(300) NOT NULL,
PRIMARY KEY (`staff_id`)
) ENGINE=innodb DEFAULT CHARSET=utf8 ;
it become
CREATE TABLE `staff` (
`staff_id` int(10) unsigned NOT NULL auto_increment,
`staff_name` varchar(300) NOT NULL,
PRIMARY KEY (`staff_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
- Run show engines in mysql, and it show
InnoDB | DISABLED | Supports transactions, row-level locking, and foreign keys
- Check mysql error file
InnoDB: Error: all log files must be created at the same time.
InnoDB: All log files must be created also in database creation.
InnoDB: If you want bigger or smaller log files, shut down the
InnoDB: database and make sure there were no errors in shutdown.
InnoDB: Then delete the existing log files. Edit the .cnf file
InnoDB: and start the database again.
Finding:
- When delete file, I forgot delete ib_logfile0 and ib_logfile1
Solution
- Stop mysqlserver
mysqladmin -uroot -ppassword shutdown
- Delete ibdata1, ibdata2, ib_logfile0,ib_logfile1
- restart mysqlserver again
sudo bin/mysqld_safe --user=mysql --default-character-set=utf8
- ibdata1, ibdata2, ib_logfile0,ib_logfile1 rebuild
- Create innodb table success
- Run show engines in mysql, and it show
show engines
- It return
InnoDB | Yes | Supports transactions, row-level locking, and foreign keys
- Stop mysql server, delete all data file and
- Recreate mysql database
sudo scripts/mysql_install_db --user=mysql --datadir=/data
- Restart mysql database
sudo bin/mysqld_safe --user=mysql --default-character-set=utf8
- The ibdata1, ibdata2 recreate and mysql start
- I create table in innodb, but table appear in myisam
CREATE TABLE `staff` (
`staff_id` int(10) unsigned NOT NULL auto_increment,
`staff_name` varchar(300) NOT NULL,
PRIMARY KEY (`staff_id`)
) ENGINE=innodb DEFAULT CHARSET=utf8 ;
it become
CREATE TABLE `staff` (
`staff_id` int(10) unsigned NOT NULL auto_increment,
`staff_name` varchar(300) NOT NULL,
PRIMARY KEY (`staff_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
- Run show engines in mysql, and it show
InnoDB | DISABLED | Supports transactions, row-level locking, and foreign keys
- Check mysql error file
InnoDB: Error: all log files must be created at the same time.
InnoDB: All log files must be created also in database creation.
InnoDB: If you want bigger or smaller log files, shut down the
InnoDB: database and make sure there were no errors in shutdown.
InnoDB: Then delete the existing log files. Edit the .cnf file
InnoDB: and start the database again.
Finding:
- When delete file, I forgot delete ib_logfile0 and ib_logfile1
Solution
- Stop mysqlserver
mysqladmin -uroot -ppassword shutdown
- Delete ibdata1, ibdata2, ib_logfile0,ib_logfile1
- restart mysqlserver again
sudo bin/mysqld_safe --user=mysql --default-character-set=utf8
- ibdata1, ibdata2, ib_logfile0,ib_logfile1 rebuild
- Create innodb table success
- Run show engines in mysql, and it show
show engines
- It return
InnoDB | Yes | Supports transactions, row-level locking, and foreign keys