需要整理mysql主从的方案,但是又懒得多安装个虚拟机来截图什么的,就搞个单机启动多实例来操作,记录下操作步骤:
1、编辑一个新的 my.cnf 文件用于新的server
cp -p /etc/my.cnf /etc/my3307.cnf ###-p是保留权限
修改配置,防止和原有配置冲突。主要需要修改的有:
- 端口(port)、socket 文件路径 (socket)、数据文件路径 (datadir);
- 如果用到 InnoDB(一般都会用到),则要修改 InnoDB 数据文件路径 (innodb_data_home_dir)、InnoDB 日志文件路径 (innodb_log_group_home_dir);
- 如果用到replication时,还要修改server的唯一id (server-id)、下载到master的binlog的存放路径 (relay-log)等。其他配置修改,则根据具体情况自行调整。
以我测试环境修改为例:
- less /etc/my.cnf
- [mysqld]
- datadir=/data/dbdata/
- skip-name-resolve
- #lower_case_table_names=1
- character-set-server = utf8
- event_scheduler=ON
- skip-name-resolve
- innodb_file_per_table=1
- log_bin_trust_function_creators=1
- wait_timeout=300
- interactive_timeout=300
- #federated
- # generic configuration options
- port = 3306
- socket = /usr/local/mysql/tmp/mysql.sock
修改my3307.cnf
- vi /etc/my3307.cnf
- [mysqld]
- datadir=/data/dbdata3307/
- skip-name-resolve
- #lower_case_table_names=1
- character-set-server = utf8
- event_scheduler=ON
- skip-name-resolve
- innodb_file_per_table=1
- log_bin_trust_function_creators=1
- wait_timeout=300
- interactive_timeout=300
- #federated
- # generic configuration options
- port = 3307
- socket = /tmp/mysql3307.sock
2、初始化DB
- /usr/local/mysql/bin/mysql_install_db --defaults-file=/etc/my3307.cnf
- chown -R mysql.mysql /data/dbdata3307
3、启动mysql
- mysqld_safe --defaults-file=/etc/my3307.cnf &
- 登陆
- mysql -S /tmp/mysql3307.sock
- mysql -S /tmp/mysql3307.sock
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 2
- Server version: 5.1.50-log Source distribution
- Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
- This software comes with ABSOLUTELY NO WARRANTY. This is free software,
- and you are welcome to modify and redistribute it under the GPL v2 license
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- root@(none) 15:12>show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | mysql |
- | test |
- +--------------------+
阅读(833) | 评论(0) | 转发(0) |