日期:2014-05-16 浏览次数:21070 次
cd /Users/XXX/Dev/mysql ./script/mysql_install_db --datadir=./data/data1 ./script/mysql_install_db --datadir=./data/data2
[mysqld_multi] mysqld = /Users/XXX/Dev/mysql/bin/mysqld_safe mysqladmin = /Users/XXX/Dev/mysql/bin/mysqladmin user = root #password = root [mysqld1] port = 3307 socket = /tmp/mysql.sock1 pid-file=/Users/XXX/Dev/mysql/data/data1/db-app1.pid log=/Users/XXX/Dev/mysql/data/data1/db-app.log datadir = /Users/XXX/Dev/mysql/data/data1 basedir = /Users/XXX/Dev/mysql user = root [mysqld2] port = 3308 socket = /tmp/mysql.sock2 pid-file = /Users/XXX/Dev/mysql/data/data2/db-app2.pid log=/Users/XXX/Dev/mysql/data/data2/db-app.log datadir = /Users/XXX/Dev/mysql/data/data2 basedir = /Users/XXX/Dev/mysql user = root [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [isamchk] key_buffer = 128M sort_buffer_size = 128M read_buffer = 2M write_buffer = 2M [myisamchk] key_buffer = 128M sort_buffer_size = 128M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout
/Users/XXX/Dev/mysql/bin/mysqld_multi --defaults-file=/Users/XXX/Dev/mysql/my.cnf start 1-2
/Users/XXX/Dev/mysql/bin/mysqld_multi --defaults-file=/Users/XXX/Dev/mysql/my.cnf stop 1-2
/Users/XXX/Dev/mysql/bin/mysqladmin -uroot -h 127.0.0.1 -P 3306 shutdown
############## 环境变量设置方法1 ################# 打开shell后, 默认在$HOME目录下 键入: vi .bash_profile 回车, 编辑.bash_profile文件 按i进入插入文字编辑模式 找到设定PATH环境变量的一行,将你要添加的完整路径(如:/Users/XXX/Dev/mysql/bin)加入其中。如果没有找到设定PATH变量的行, 你可以自己添加一行: export PATH=${PATH}:/Users/XXX/Dev/mysql/bin ############ 环境变量设置方法2(推荐) ############## 在 /etc/paths.d 建立一个文件专门表示mysql的path 1)浏览到 /etc/paths.d : cd /etc/paths.d 2)创建文件: sudo vi mysql 3)编辑模式下输入: /Users/XXX/Dev/mysql/bin 4)可以在terminal下输入以下命令验证是否生效: echo $PATH
mysqladmin -u root -h 127.0.0.1 -P 3307 password [yourpassword] mysqladmin -u root -h 127.0.0.1 -P 3308 password [yourpassword]
cd /Library/StartupItems sudo mkdir MysqlMulti
sudo vi /Library/StartupItems/MysqlMulti/MysqlMulti
#!/bin/sh # Source common setup, including hostconfig. # . /etc/rc.common StartService( ) { ConsoleMessage "Starting MySQL" /Users/XXX/Dev/mysql/bin/mysqld_multi --defaults-file=/Users/XXX/Dev/mysql/my.cnf start 1-2 } StopService( ) { ConsoleMessage "Stopping MySQL" /Users/XXX/Dev/mysql/bin/mysqld_multi --defaults-file=/Users/XXX/Dev/mysql/my.cnf stop 1-2 } RestartService( ) { ConsoleMessage "Restarting MySQL" StopService StartService