因为是多实例,其中参数需要修改,修改后的配置文件如下:配置文件my.cnf
- [client]
- port = 3307
- socket = /data/3307/mysql.sock
- [mysql]
- no-auto-rehash
- [mysqld] user = mysql
- port = 3307
- socket = /data/3307/mysql.sock
- basedir = /application/mysql
- datadir = /data/3307/data
- #log_long_format
- #log-error = /data/3307/error.log
- #log-slow-queries = /data/3307/slow.log
- pid-file = /data/3307/mysql.pid
- server-id = 3
- [mysqld_safe]
- log-error=/data/3307/mysql3307.err
- pid-file=/data/3307/mysqld.pid
启动程序文件mysql
- [root@backup 3307]# cat mysql
- #!/bin/sh
- init port=3307
- mysql_user="root"
- mysql_pwd="migongge"
- CmdPath="/application/mysql/bin"
- mysql_sock="/data/${port}/mysql.sock"
- #startup
- function_start_mysql() {
- if [ ! -e "$mysql_sock" ];then
- printf "Starting MySQL...n"
- /bin/sh ${CmdPath}/mysqld_safe --defaults-file=/data/${port}/my.cnf 2>&1 > /dev/null &
- else
- printf "MySQL is running...n"
- exit
- fi
- }
- #stop function
- function_stop_mysql() {
- if [ ! -e "$mysql_sock" ];then
- printf "MySQL is stopped...n"
- exit
- else
- printf "Stoping MySQL...n"
- ${CmdPath}/mysqladmin -u ${mysql_user} -p${mysql_pwd} -S /data/${port}/mysql.sock shutdown
- fi
- }
- #restart function
- function_restart_mysql() {
- printf "Restarting MySQL...n"
- function_stop_mysql
- sleep 2
- function_start_mysql
- }
- case $1 in
- start)
- function_start_mysql
- ;;
- stop)
- function_stop_mysql
- ;;
- restart)
- function_restart_mysql
- ;;
- *)
- printf "Usage: /data/${port}/mysql {start|stop|restart}n"
- esac
其它的配置可参考配置文件进行修改即可
多实例初始化操作
- [root@centos6 3306]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/data/3306/data --user=mysql
- Installing MySQL system tables...
- 161209 18:02:17 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
- 161209 18:02:17 [Note] /application/mysql/bin/mysqld (mysqld 5.5.52-log) starting as process 3336 ...
- OK
- Filling help tables...
- 161209 18:02:17 [Warning] 'THREAD_CONCURRENCY' is deprecated and will be removed in a future release.
- 161209 18:02:17 [Note] /application/mysql/bin/mysqld (mysqld 5.5.52-log) starting as process 3343 ...
- 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 centos6 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 at http://bugs.mysql.com/
(编辑:晋中站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|