• Mysql多实例安装笔记


    参考:
    系统:KaliLinux (x86_64)

    软件下载

    1、下载地址:
    2、选择5.6版本

    安装

    1、准备文件和目录

    tar -zxvf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
    cd /usr/local/
    ln -sv mysql-5.6.40-linux-glibc2.12-x86_64 mysql
    
    mkdir -pv /data/mysql_3306
    mkdir -pv /data/mysql_3307
    mkdir -pv /data/mysql_3306/{data,log}
    mkdir -pv /data/mysql_3307/{data,log}
    

    2、修改权限

    chown -R mysql.mysql /usr/local/mysql
    chown -R mysql.mysql /data
    
    

    3、初始化数据

    /usr/local/mysql/scripts/mysql_install_db --datadir=/data/mysql_3306/data --user=mysql --basedir=/usr/local/mysql --no-defaults
    /usr/local/mysql/scripts/mysql_install_db --datadir=/data/mysql_3307/data --user=mysql --basedir=/usr/local/mysql --no-defaults
    

    4、配置文件

    • /etc/my3306.cnf
    [client]
    user=root
    port=3306  
    socket=/tmp/mysql.sock  
     
    [mysqld] 
    user=mysql  
    basedir = /usr/local/mysql  
    datadir=/data/mysql_3306/data
    pid-file=/data/mysql_3306/data/mysql_3306.pid
    port=3306  
    server_id=3306  
    socket=/tmp/mysql_3306.sock  
    character_set_server = utf8
    skip_name_resolve = 1
    max_connections = 800
    max_connect_errors = 1000
    max_allowed_packet = 16777216  
    log-error = /data/mysql_3306/log/error.log  
    binlog_format = mixed  
    expire_logs_days = 30
    log-bin = /data/mysql_3306/log/mysql-bin.log  
    log-bin-index = /data/mysql_3306/log/mysql-bin.index
    
    • /etc/my3307.cnf
    [client]
    root=root
    port=3307
    socket=/tmp/mysql.sock  
     
    [mysqld] 
    user=mysql  
    basedir = /usr/local/mysql  
    datadir=/data/mysql_3307/data
    pid-file=/data/mysql_3307/data/mysql_3307.pid
    port=3307  
    server_id=3307  
    socket=/tmp/mysql_3307.sock  
    character_set_server = utf8
    skip_name_resolve = 1
    max_connections = 800
    max_connect_errors = 1000
    max_allowed_packet = 16777216
    log-error = /data/mysql_3307/log/error.log  
    binlog_format = mixed  
    expire_logs_days = 30
    log-bin = /data/mysql_3307/log/mysql-bin.log  
    log-bin-index = /data/mysql_3307/log/mysql-bin.index
    

    5、启动服务

    /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my3306.cnf &
    /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my3306.cnf &
    

    6、连接服务

    mysql -S /tmp/mysql_3306.sock
    mysql -S /tmp/mysql_3307.sock
    或
    /usr/local/mysql/bin/mysql -h 127.0.0.1 -P3306
    /usr/local/mysql/bin/mysql -h 127.0.0.1 -P3307
    
  • 相关阅读:
    Redis分布式锁的正确加锁与解锁方式
    高并发系统中的限流算法
    谈谈 InnoDB引擎中的一些索引策略
    面试必问:手写一个内存泄漏的程序
    空指针异常与Optional类
    Redis的内存淘汰策略
    explain的关键字段的意义
    pycharm编辑器简单配置-- 持续更新完善
    vscode 插件-better comments-代码注释高亮
    阿里前端开发规范-转载
  • 原文地址:https://www.cnblogs.com/lanqie/p/8946379.html
Copyright © 2020-2023  润新知