/data
├── 3306
│ ├── data
│ └── my.cnf
└── 3307
├── data
└── my.cnf
pkill mysqld
多实例启动文件的启动MySQL服务实质:
mysql_safe --default-file=/data/3306/my.cnf 2&1 > /dev/null &
mysql_safe --default-file=/data/3307/my.cnf 2&1 > /dev/null &
停止 平滑关闭
mysqladmin -u root -p123456 -S /data/3306/mysql.sock shutdown
mysqladmin -u root -p123456 -S /data/3307/mysql.sock shutdown
/data
├── 3306
│ ├── data
│ ├── my.cnf
│ └── mysql
└── 3307
├── data
├── my.cnf
└── mysql chown -R mysql.mysql /data find /data/ -type f -name "mysql" | xargs chmod +x
初始化mysql数据库文件:创建基础的数据库文件
cd /application/mysql/scripts/
./mysql_install_db --basedir=/application/mysql --datadir=/data/3306/data --user=mysql
./mysql_install_db --basedir=/application/mysql --datadir=/data/3307/data --user=mysql
启动
/data/3306/mysql start
/data/3307/mysql start
netstat -lntup | grep 330
tail -l /data/3306/mysql_oldboy3306.err cd /data/3307 vim mysql //启动文件 mysql_user="root" mysql_pwd="123456" mysql -S /data/3306/mysql.sock //进入mysql
mysql> system mysql -S /data/3306/mysql.sock // 在mysql里面切换
mysqladmin -u root -S /data/3306/mysql.sock password '123123'
mysqladmin -u root -S /data/3306/mysql.sock -p'123123' password '123456' find /data/ -type f -name "mysql" -exec chmod 700 {} \; find /data/ -type f -name "mysql" -exec chown root.root {} \; pkill mysqld
/data/3306/mysql start
/data/3307/mysql start
ps -ef | grep mysql
root 6780 1 0 05:05 pts/0 00:00:00 /bin/sh /application/mysql/bin/mysqld_safe --defaults-file=/data/3306/my.cnf
root 6824 1 0 05:05 pts/0 00:00:00 /bin/sh /application/mysql/bin/mysqld_safe --defaults-file=/data/3307/my.cnf
mysql 8186 6780 0 05:05 pts/0 00:00:00 /application/mysql-5.5.32/bin/mysqld --defaults-file=/data/3306/my.cnf --basedir=/application/mysql --datadir=/data/3306/data --plugin-dir=/application/mysql/lib/plugin --user=mysql --log-error=/data/3306/mysql_oldboy3306.err --open-files-limit=1024 --pid-file=/data/3306/mysqld.pid --socket=/data/3306/mysql.sock --port=3306
mysql 8203 6824 0 05:05 pts/0 00:00:00 /application/mysql-5.5.32/bin/mysqld --defaults-file=/data/3307/my.cnf --basedir=/application/mysql --datadir=/data/3307/data --plugin-dir=/application/mysql/lib/plugin --user=mysql --log-error=/data/3307/mysql_oldboy3307.err --open-files-limit=1024 --pid-file=/data/3307/mysqld.pid --socket=/data/3307/mysql.sock --port=3307
增加3308
mkdir /data/3308/data/ -p
cp /data/3306/my.cnf /data/3308/
cp /data/3306/mysql /data/3308/
chown -R mysql.mysql /data/3308/
cd /data/3308/
vim my.cnf
server-id = 4
:%s/3306/3308/g
vim mysql
cd /application/mysql/scripts/
[root@localhost scripts]# ./mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/data/3308/data/
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/application/mysql/bin/mysqladmin -u root password 'new-password'
/application/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/application/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /application/mysql ; /application/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /application/mysql/scripts/mysqlbug script!
/data/3308/mysql start
mysqladmin -u root -S /data/3308/mysql.sock password '123456'