It took three days for me to get started with LINUX for the first time. I hope it will bring convenience to everyone.
It took three days for me to get started with LINUX for the first time. I hope it will bring convenience to everyone.
1. Download the MYSQL source code version from the MYSQL official website [must be the source code version]
2. Press the following code to type the LINUX Command Line
The Code is as follows:
[Note] adding mysql groups and users
# Groupadd mysql
# Useradd-g mysql
[Note] unpackage to/usr/local
# Tar-xzf mysql-standard-4.1.9-pc-linux-gnu-i686.tar.gz-C/usr/local
[Note] creating a soft link is convenient (this connection can be named mysql001 or another name)
# Cd/usr/local
# Ln-s mysql-standard-5.0.15-linux-i686-glibc23 mysql001
# Cd mysql001
# Scripts/mysql_install_db
# Chown-R root.
# Chown-R mysql data
# Chgrp-R mysql.
[Note] Copy data for allocation of multiple instances in a single version
# Cp-a data data_1
# Cp-a data data_2
[Note] Add a multi-instance configuration file
# Cd/usr/local/mysql001/bin
# Cat> my_multi.cnf
[Note] the following is the configuration information of my_multi.cnf, which can be copied accordingly.
[Mysqld_multi]
Mysqld =/usr/local/mysql001/bin/mysqld_safe
Mysqladmin =/usr/local/mysql001/bin/mysqladmin
User = root
Password = root
[Mysqld1]
Socket =/tmp/mysql_001.sock
Port = 3301
Pid-file =/usr/local/mysql001/data_1/hostname. pid
Datadir =/usr/local/mysql001/data_1
Log =/usr/local/mysql001/data_1/hostname. log
User = mysql
# Slave setting
Server-id = 2
Master-host = 192.168.1.85
Master-port = 3306
Master-user = backup
Masters-password = 123456
Replicate-do-db = gs_database
Replicate-do-db = gs_log
Master-connect-retry = 30
[Mysqld2]
Socket =/tmp/mysql_5_2.sock
Port = 3302
Pid-file =/usr/local/mysql001/data_2/hostname. pid
Datadir =/usr/local/mysql001/data_2
Log =/usr/local/mysql001/data_2/hostname. log
User = mysql
# Slave setting
Server-id = 3
Master-host = 192.168.1.69
Master-port = 3306
Master-user = backup
Masters-password = 123
Replicate-do-db = gs_databaes
Replicate-do-db = gs_log
Master-connect-retry = 30
CTRL + D to exit.
The Code is as follows:
# Vi/etc/profile # Add system environment variables.
Export MYSQL_HOME =/usr/local/mysql001/bin
Export PATH = $ PATH: $ MYSQL_HOME
Restart the system to make environment variables take effect.
Add to enable automatic start. [do not add this parameter here. You can decide whether to enable automatic start based on your situation]
The Code is as follows:
Vi/etc/rc. local
# Add
Mysqld_multi -- defaults-extra-file =/usr/local/src/mysql_dir/bin/my_multi.cnf start 1, 2
3. Other skills
# Access an instance:
Mysql-u root-S/tmp/mysql_5_1.sock-p
# Set the password of each instance:
Mysqladmin-u root password 'root'-S/tmp/mysql_5_1.sock
# Manually start each instance:
Mysqld_multi -- defaults-extra-file =/usr/local/src/mysql_dir/bin/my_multi.cnf start 1, 2
# Stop instances:
Mysqld_multi -- defaults-extra-file =/usr/local/src/mysql_dir/bin/my_multi.cnf stop 1, 2
# References
Http://blog.liuts.com/post/13/
It took three days for me to get started with LINUX for the first time. I hope it will bring convenience to everyone.