• 同时运行两个mysql实例


    1. 修改/etc/mysql/my.cnf

    加入

    [mysqld_multi]
    mysqld = /usr/bin/mysqld_safe
    mysqladmin = /usr/bin/mysqladmin
    user = multi_admin
    password = multipass

    把原来的[mysqld]改成[mysqld001],并加入[mysqld002],分别配置两个实例,主要是下面这些设置要不同:

    pid-file
    socket
    port
    datadir

    2. 设置用户

    $ mysql -u root -S /var/run/mysqld/mysqld.sock -p
    > GRANT SHUTDOWN ON *.* TO 'multi_admin'@'localhost' IDENTIFIED BY 'multipass';
    $ mysql -u root -S /var/run/mysqld/mysqld2.sock -p
    > GRANT SHUTDOWN ON *.* TO 'multi_admin'@'localhost' IDENTIFIED BY 'multipass';

    3. 测试启动停止命令

    $ mysqld_multi --no-log --config-file=/etc/mysql/my.cnf start 001,002
    $ mysqld_multi --no-log --config-file=/etc/mysql/my.cnf stop 001,002
    $ mysqld_multi --no-log --config-file=/etc/mysql/my.cnf report 001,002

    4. 新建启动脚本 /etc/init.d/mysql-multi替换原来的启动脚本/etc/init.d/mysql

    5. 修改/etc/phpmyadmin/config.inc.php,配置如何连接这两个服务器

    $i = 0;
    $i++;
    $cfg['Servers'][$i]['host'] = 'localhost';
    $cfg['Servers'][$i]['socket'] = '/var/run/mysqld/mysqld.sock';
    $cfg['Servers'][$i]['connect_type'] = 'socket';
    $cfg['Servers'][$i]['verbose'] = 'localhost:3306';
    $i++;
    $cfg['Servers'][$i]['host'] = 'localhost';
    $cfg['Servers'][$i]['socket'] = '/var/run/mysqld/mysqld2.sock';
    $cfg['Servers'][$i]['connect_type'] = 'socket';
    $cfg['Servers'][$i]['verbose'] = 'localhost:3307';

  • 相关阅读:
    [LeetCode] 64. 最小路径和 ☆☆☆(动态规划)
    [LeetCode] 62. 不同路径 ☆☆☆(动态规划)
    [LeetCode] 25. K 个一组翻转链表 ☆☆☆☆☆(链表)
    jquery validate 多种使用方式
    javascript 闭包学习
    javascript prototype学习
    jquery中event对象属性与方法小结
    html5获取地理位置信息
    thinkphp 构建子查询
    mongodb gridfs基本使用
  • 原文地址:https://www.cnblogs.com/orochihuang/p/2527190.html
Copyright © 2020-2023  润新知