Category Archives: MySQL

Migrate from mysql to percona

1
2
gpg --keyserver hkp://keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
gpg -a --export CD2EFD2A | sudo apt-key add -

add to /etc/apt/sources.list.d/percona.list

1
2
deb http://repo.percona.com/apt VERSION main
deb-src http://repo.percona.com/apt VERSION main

where VERSION is a name of your ubuntu version,
you can get it by command

1
lsb_release -a |grep name |awk '{print $2}'

backup data

1
2
cp -Rf /var/lib/mysql /var/lib/mysql-old
cp /etc/my.cnf /etc/my.cnf-old

Install percona (it automatically removes mysql and converts databases)

1
2
apt-get update
apt-get install percona-server-server-5.5 percona-server-client-5.5

Part of this article was taken from http://planet.jboss.org/post/drop_in_migration_from_mysql_to_percona_db_in_two_minutes

IT Security Brothers (http://itsb.pro)

Hi guys, I would like to present you our new project IT Security Brothers http://itsb.pro
We provide pentest, consultations and IT outsourcing services.
Feel free to hire us for IT jobs.

MySQL: Unknown table engine ‘InnoDB’

mysql> show innodb status
Unknown table engine ‘InnoDB’

I got this message when tried to allocate a huge size of memory on remote server,
innodb_buffer_pool_size = 8000M

after i have looked for memory:
free -m
and have found that there are only 4gb,

change option to:
innodb_buffer_pool_size = 2000M

and mysql has been start fine with innodb.

MySQL: upgrade from 5.0 to 5.1

1) stop all applications which works with mysql
2) make mysqldump(with right options like --single-transaction and --master-data)
3) make logs flush; in mysql
4) stop mysql
5) backup /var/lib/mysql folder (it's default path to mysql folder)
6) install new version of mysql (in ubuntu: aptitude install mysql-server-5.1
7) execute mysql_upgrade command in console
8) start mysql

MySQL: Transactions in MyISAM and InnoDB

Test

CREATE TABLE `t01` (
`column_of_t01` int(11) DEFAULT NULL
) ENGINE=MyISAM;

CREATE TABLE `t02` (
`column_of_t02` int(11) DEFAULT NULL
) ENGINE=InnoDB;
start transaction;
insert into t01(column_of_t01) values(666);
insert into t02(column_of_t02) values(666);
select * from t01;
select * from t02;
rollback;
select * from t01;
select * from t02;

Continue reading MySQL: Transactions in MyISAM and InnoDB

mysql 5.1: replication

Master server

edit /etc/mysql/conf.d/replication.cnf

1
[mysqld]

1
server-id        =
1
1

1
# By
1
default
1
, the directory is written to the directory of database.

1
# IMPORTANT: If you lose the base, having a backup and binary logs, you can restore a database at the time of collapse. For
1
this

1
# reason, the logs and databases should be stored at physically different carriers.

1
log-bin          = /db/log/mysql-bin.log

1
# This variable applies when binary logging is enabled. It controls whether stored function creators can be trusted not to create #stored functions that will cause unsafe events to be written to the binary log.

1
log_bin_trust_function_creators =
1
1

1
# The number of days
1
for
1
automatic binary log file removal..

1
expire_logs_days =
1
90

1
# >=
1
5.1
1
.
1
28
1
- you is unable to start shard without
1
this
1
option.

1
# < 
1
5.1

   

1
- you is unable to start mysqld server without
1
this
1
option.

1
binlog_format    = MIXED

1
max_binlog_size  = 100M
# In addition, the transaction can determine what needs to change the data and may be useful to diagnose various problems.
# For MySQL <= 5.0: We don't recommend to use this option due to the replication became fragile.

mysql -uroot -p

1
GRANT REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO replicator@
1
'%'
1
IDENTIFIED BY
1
'****'
1
;

/etc/init.d/mysql restart
Continue reading mysql 5.1: replication