public
Created

Start a MySQL master/slave pair.

  • Download Gist
start_sql_servers.sh
Shell
1 2 3 4 5 6 7 8 9 10 11
rm -R $HOME/Desktop/server-{1,2}
mkdir -p $HOME/Desktop/server-{1,2}
 
mysql_install_db --datadir=$HOME/Desktop/server-1 && mysqld --server-id 1 -h ~/Desktop/server-1 --socket ~/Desktop/server-1/mysql.sock -P 10001 --log-bin &
mysql_install_db --datadir=$HOME/Desktop/server-2 && mysqld --server-id 2 -h ~/Desktop/server-2 --socket ~/Desktop/server-2/mysql.sock -P 10002 --master-port=10001 --master-host=127.0.0.1 --master-user=root &
 
alias sql-master="mysql -h127.0.0.1 -P10001 -uroot"
alias sql-slave="mysql -h127.0.0.1 -P10002 -uroot"
 
alias sql-master-admin="mysqladmin -h127.0.0.1 -P10001 -uroot"
alias sql-slave-admin="mysqladmin -h127.0.0.1 -P10002 -uroot"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.