Table of Contents
Download and save mysql source archive from http://dev.mysql.com/downloads/
cd /usr/local/src tar -xzf mysql-X.X.X.tar.gz cd mysql-X.X.X ./configure --prefix=/usr/local/mysql-X.X.X make make install
Install binaries and create required user and directories.
ln -s /usr/local/mysql-X.X.X /usr/local/mysql groupadd mysql useradd -g mysql mysql mkdir -p /var/log/mysql/ chown mysql.mysql /var/log/mysql mkdir /var/run/mysqld/ chown -R mysql.mysql /var/run/mysqld
Initialize mysql files.
mkdir -p /var/local/mysql/data/ chown -R mysql.mysql /var/local/mysql/data/ su mysql -c "/usr/local/mysql/bin/mysql_install_db --force --datadir=/var/local/mysql/data/"
Create default configuration files.
mkdir -p /etc/mysql mv /usr/local/mysql/conf /etc/mysql ln -sf /etc/mysql/conf /usr/local/mysql/ chown -R mysql.mysql /etc/mysql
Add mysql commands in PATH by modifying /etc/profile.
PATH=$PATH:/usr/local/mysql/bin export PATH
Copy default startup script.
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
Adapt it.
basedir=/usr/local/mysql datadir=/var/local/mysql/data
If you are using dash as the default shell, change the first line with
#!/bin/bash
The configuration file won't be found unless explicitly mentioned. Change the line
$bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
with
$bindir/mysqld_safe --defaults-file=/etc/mysql/conf/my.cnf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
Add execution right and register automatic startup.
chmod a+x /etc/init.d/mysql update-rc.d -f mysql defaults
Detailed steps are available at: http://dev.mysql.com/doc/refman/5.0/en/replication-howto.html
Give rights to slaves (using mysql client):
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.mydomain.com' IDENTIFIED BY 'slavepass';
Edit configuration file to add an id and logging facilities:
[mysqld] log-bin=mysql-bin server-id=1
And restart mysql.
Edit configuration file to add an id:
[mysqld] log-bin=mysql-bin server-id=N
Setup the replication (using mysql client):
CHANGE MASTER TO MASTER_HOST='master_host_name', MASTER_USER='replication_user_name', MASTER_PASSWORD='replication_password', MASTER_LOG_FILE='', MASTER_LOG_POS=4;
and start the slave:
START SLAVE;