zoukankan      html  css  js  c++  java
  • mysql多实例部署

    //下载(略),解压
    [root@slave ~]# tar -xf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz 
    [root@slave ~]# yum -y install libncurses*
    //创建数据库文件夹
    [root@slave ~]#  mkdir -p /opt/data/{3306,3307}
    
    //创建根用户mysql
    [root@slave ~]# useradd -r -s /usr/sbin/nologin mysql
    
    //将mysql解压文件夹移动到指定目录
    [root@slave ~]# mv mysql-5.7.31-linux-glibc2.12-x86_64 /usr/local/
    
    //创建软链接
    [root@slave ~]# ln -s /usr/local/mysql-5.7.31-linux-glibc2.12-x86_64/ /usr/local/mysql
    [root@slave ~]# ln -s  /usr/local/mysql/include/ /usr/local/include/mysql
    
    //增加环境变量
    [root@slave ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH'> /etc/profile.d/mysql.sh
    [root@slave ~]# . /etc/profile.d/mysql.sh
    [root@slave ~]# echo $PATH
    /usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
    
    //增加帮助文档和库文件匹配路径
    [root@slave ~]# vim /etc/man_db.conf 
    MANDATORY_MANPATH                       /usr/local/mysql/man
    [root@slave ~]# vim /etc/ld.so.conf.d/mysql.conf
    /usr/local/mysql/lib
    [root@slave ~]# ldconfig
    
    //初始化两个实例机,保存临时密码
    [root@slave ~]# mysqld --initialize --basedir=/opt/data/3306 --user=mysql
    [root@slave ~]# echo 'XJth1eIC-EXa'>passwd3306
    [root@slave ~]#  mysqld --initialize --basedir=/opt/data/3307 --user=mysql
    [root@slave ~]# echo '*g5(Rij+j1wV'>passwd3307
    
    //安装perl命令
    [root@slave ~]# yum -y install perl
    Complete!
    
    //配置多实例文件
    [root@slave ~]# vim /etc/my.cnf
    ...
    [mysqld_multi]
    mysqld = /usr/local/mysql/bin/mysqld_safe
    mysqladmin = /usr/local/mysql/bin/mysqladmin
    
    [mysqld3306]
    datadir = /opt/data/3306
    port = 3306
    socket = /tmp/mysql3306.sock
    pid-file = /opt/data/3306/mysql_3306.pid
    log-error=/var/log/3306.log
    [mysqld3307]
    datadir = /opt/data/3307
    port = 3307
    socket = /tmp/mysql3307.sock
    pid-file = /opt/data/3307/mysql_3306.pid
    log-error=/var/log/3307.log
    
    //启动服务3306
    [root@slave ~]# mysqld_multi start 3306
    Installing new database in /opt/data/3306
    ...
    2021-01-03T08:26:40.212207Z 1 [Note] A temporary password is generated for root@localhost: XJth1eIC-EXa
    //启动服务3307
    [root@slave ~]# mysqld_multi start 3307
    Installing new database in /opt/data/3307
    
    ...
    2021-01-03T08:27:06.142304Z 1 [Note] A temporary password is generated for root@localhost: /jsSxslpl0-t
    
    //查看监听端口
    [root@slave ~]# ss -antl
    State             Recv-Q            Send-Q                       Local Address:Port                       Peer Address:Port           
    LISTEN            0                 128                                0.0.0.0:22                              0.0.0.0:*              
    LISTEN            0                 80                                       *:3306                                  *:*              
    LISTEN            0                 80                                       *:3307                                  *:*              
    LISTEN            0                 128                                   [::]:22                                 [::]:*   
    
    //登录重置密码
    //3307端
    [root@slave ~]# mysql -uroot  -p'/jsSxslpl0-t' -S /tmp/mysql3307.sock 
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.31
    
    Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> set password=password('123456');
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    //3306端
    [root@slave ~]# mysql -uroot  -p'XJth1eIC-EXa' -S /tmp/mysql3306.sock 
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 9
    Server version: 5.7.31
    
    Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> set password=password('123456');
    Query OK, 0 rows affected, 1 warning (0.01 sec)
    
    
  • 相关阅读:
    spring-mybatis 事物配置 execution表达式含义
    微信内置浏览器缓存导致链接无法多次访问
    linux学习记录-------解决复制的虚拟机,无法同时上网
    mybatis-select-insert-update-delete
    tomcat 端口被占用
    EFCodeFirst安装失败(包括EntityFrameWork安装),这样解决。。。
    数组的一些操作
    《Java技术》第三次作业--面向对象——继承、抽象类、接口
    java第二次作业
    《Java技术》第一次作业
  • 原文地址:https://www.cnblogs.com/fangxinxin/p/14226048.html
Copyright © 2011-2022 走看看