码迷,mamicode.com
首页 > 数据库 > 详细

mysqld_multi配置MySQL多实例(编译安装的mysql)

时间:2015-06-30 18:43:47      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:mysql   多实例   

1编译安装mysql

    tar zxf mysql-5.1.73.tar.gz

    cd mysql-5.1.73

    ./configure --prefix=/usr/local/mysql \

    --enable-assembler \

    --with-extra-charsets=complex \

    --enable-thread-safe-client \

    --with-big-tables \

    --with-readline \

    --with-ssl \

    --with-embedded-server \

    --enable-local-infile \

    --with-plugins=partition,innobase \

    --with-plugin-PLUGIN \

    --with-mysqld-ldflags=-all-static \

    --with-client-ldflags=-all-static


    make && make install


2创建mysqld_multi的配置文件    (只有几条必要参数)

    vim /usr/local/mysql/conf/my.cnf

    

    [mysqld_multi]

    mysqld     = /usr/local/mysql/bin/mysqld_safe

    mysqladmin = /usr/local/mysql/bin/mysqladmin

    user       = root        (MySQL的用户和密码,与操作系统用户无关,数据库里必须有相应的用

    password   = 111111       户和密码)


    [mysqld3306]

    socket     = /data/3306/3306.sock

    port       = 3306

    pid-file   = /data/3306/3306.pid

    datadir    = /data/3306/data/

    log        = /data/3306/3306.log


    [mysqld3307]

    socket     = /data/3307/3307.sock

    port       = 3307

    pid-file   = /data/3307/3307.pid

    datadir    = /data/3307/data/

    log        = /data/3307/3307.log


3创建多实例

    mkdir -p /data/{3306,3307}/data

    chown -R mysql.mysql /data

    /usr/local/mysql/bin/mysql_install_db --datadir=/data/3306/data/ --user=mysql(初始化实例3306)

    /usr/local/mysql/bin/mysql_install_db --datadir=/data/3307/data/ --user=mysql(初始化实例3307)


4启动实例

    /usr/local/mysql/bin/mysqld_multi --defaults-extra-file=/usr/local/mysql/conf/my.cnf start 3306    (启动实例3306)

    /usr/local/mysql/bin/mysqld_multi --defaults-extra-file=/usr/local/mysql/conf/my.cnf start 3307    (启动实例3307)

    /usr/local/mysql/bin/mysqld_multi --defaults-extra-file=/usr/local/mysql/conf/my.cnf start 3306-3307  (同时启动)


5修改mysql的root用户的密码

    mysql -uroot password 123456 -S /data/3306/3306.sock    (无密码,直接设置密码为123456)

    mysql -uroot -p123456 -S /data/3306/3306.sock    (修改密码,123456为新密码,输入回车后会提示输入原密码)


6停止实例

    与启动实例命令相同,把start换成stop

本文出自 “little_monkey” 博客,谢绝转载!

mysqld_multi配置MySQL多实例(编译安装的mysql)

标签:mysql   多实例   

原文地址:http://xiaohou187.blog.51cto.com/9162101/1669415

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!