• 同时运行两个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';

  • 相关阅读:
    Exp8-Web综合
    Exp7-网络欺诈防范
    Exp6-MSF应用基础
    加密API学习
    Exp5 信息搜集与漏洞扫描
    Exp4-恶意代码分析
    Exp3-免杀原理
    Exp2-后门原理与实践
    leetcode 22括号生成 暴力法
    413 等差数列划分
  • 原文地址:https://www.cnblogs.com/orochihuang/p/2527190.html
Copyright © 2020-2023  润新知