展开菜单
首页 精品内容 本月促销 装机必备 Windows PDF教程 macOS软件 IOS软件 Android AI 专题
全部分类

当前位置:

首页 > 编程开发 > mysql多实例如何部署

mysql多实例如何部署

mysql多实例部署软件下载[root@lnh~]#rpm-qa|grepmysql[root@lnh~]#ss-antlStateRecv-QSend-QLocalAddress:PortPeerAddress:PortProcessLISTEN01280.0.0.0:220.0.0.0:*LISTEN0128[::]:22[::]:*//验证一下是否有mysql[root@lnh~]#cd/usr/src/[root@lnhsrc]#wgethttps://downloads.mysql.com/ar

本文目录

    mysql多实例部署

    软件下载

    [root@lnh ~]# rpm -qa |grep mysql
    [root@lnh ~]# ss -antl
    State    Recv-Q   Send-Q     Local Address:Port      Peer Address:Port   Process   
    LISTEN   0        128              0.0.0.0:22             0.0.0.0:*                
    LISTEN   0        128                 [::]:22                [::]:*                
    //验证一下是否有mysql
    [root@lnh ~]# cd /usr/src/
    [root@lnh src]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
    --2022-07-31 14:25:22--  https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
    Resolving downloads.mysql.com (downloads.mysql.com)... 23.10.6.175, 2600:1405:1800:19c::2e31, 2600:1405:1800:184::2e31
    Connecting to downloads.mysql.com (downloads.mysql.com)|23.10.6.175|:443... connected.
    HTTP request sent, awaiting response... 302 Moved Temporarily
    Location: https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz [following]
    --2022-07-31 14:25:23--  https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
    Resolving cdn.mysql.com (cdn.mysql.com)... 23.212.157.5
    Connecting to cdn.mysql.com (cdn.mysql.com)|23.212.157.5|:443... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 674830866 (644M) [application/x-tar-gz]
    Saving to: ‘mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz'
    
    mysql-5.7.38-linux-g 100%[=====================>] 643.57M  1.88MB/s    in 8m 54s  
    
    2022-07-31 14:34:17 (1.21 MB/s) - ‘mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz' saved [674830866/674830866]
    //在www.mysql.com里面进行复制下载地址
    [root@lnh src]# ls
    debug  kernels  mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz

    配置用户并解压二进制程序至/usr/local下

    [root@lnh src]# useradd -r -M -s /sbin/nologin mysql
    [root@lnh src]# id mysql
    uid=993(mysql) gid=990(mysql) groups=990(mysql)
    [root@lnh src]# tar -xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
    [root@lnh src]# cd /usr/local/
    [root@lnh local]# ll    //查看解压的东西
    total 0
    drwxr-xr-x. 14 root root 164 Jul 21 21:32 apache
    drwxr-xr-x.  6 root root  58 Jul 21 21:12 apr
    drwxr-xr-x.  5 root root  43 Jul 21 21:17 apr-util
    drwxr-xr-x.  2 root root   6 May 19  2020 bin
    drwxr-xr-x.  2 root root   6 May 19  2020 etc
    drwxr-xr-x.  2 root root   6 May 19  2020 games
    drwxr-xr-x.  2 root root   6 May 19  2020 include
    drwxr-xr-x.  2 root root   6 May 19  2020 lib
    drwxr-xr-x.  3 root root  17 Jul 19 16:13 lib64
    drwxr-xr-x.  2 root root   6 May 19  2020 libexec
    drwxr-xr-x.  9 root root 129 Jul 31 14:56 mysql-5.7.38-linux-glibc2.12-x86_64
    drwxr-xr-x.  2 root root   6 May 19  2020 sbin
    drwxr-xr-x.  5 root root  49 Jul 19 16:13 share
    drwxr-xr-x.  5 root root 145 Jul 21 21:19 src
    [root@lnh local]# ln -sv mysql-5.7.38-linux-glibc2.12-x86_64 mysql     //做一个软链接              //-v是将结果打印出来   
    'mysql' -> 'mysql-5.7.38-linux-glibc2.12-x86_64'
    [root@lnh local]# ll   //查看
    total 0
    drwxr-xr-x. 14 root root 164 Jul 21 21:32 apache
    drwxr-xr-x.  6 root root  58 Jul 21 21:12 apr
    drwxr-xr-x.  5 root root  43 Jul 21 21:17 apr-util
    drwxr-xr-x.  2 root root   6 May 19  2020 bin
    drwxr-xr-x.  2 root root   6 May 19  2020 etc
    drwxr-xr-x.  2 root root   6 May 19  2020 games
    drwxr-xr-x.  2 root root   6 May 19  2020 include
    drwxr-xr-x.  2 root root   6 May 19  2020 lib
    drwxr-xr-x.  3 root root  17 Jul 19 16:13 lib64
    drwxr-xr-x.  2 root root   6 May 19  2020 libexec
    lrwxrwxrwx.  1 root root  35 Jul 31 14:58 mysql -> mysql-5.7.38-linux-glibc2.12-x86_64
    drwxr-xr-x.  9 root root 129 Jul 31 14:56 mysql-5.7.38-linux-glibc2.12-x86_64
    drwxr-xr-x.  2 root root   6 May 19  2020 sbin
    drwxr-xr-x.  5 root root  49 Jul 19 16:13 share
    drwxr-xr-x.  5 root root 145 Jul 21 21:19 src
    [root@lnh local]# chown -R mysql.mysql mysql*  //将软链接的属主属组改成mysql的
    [root@lnh local]# ll
    total 0
    drwxr-xr-x. 14 root  root  164 Jul 21 21:32 apache
    drwxr-xr-x.  6 root  root   58 Jul 21 21:12 apr
    drwxr-xr-x.  5 root  root   43 Jul 21 21:17 apr-util
    drwxr-xr-x.  2 root  root    6 May 19  2020 bin
    drwxr-xr-x.  2 root  root    6 May 19  2020 etc
    drwxr-xr-x.  2 root  root    6 May 19  2020 games
    drwxr-xr-x.  2 root  root    6 May 19  2020 include
    drwxr-xr-x.  2 root  root    6 May 19  2020 lib
    drwxr-xr-x.  3 root  root   17 Jul 19 16:13 lib64
    drwxr-xr-x.  2 root  root    6 May 19  2020 libexec
    lrwxrwxrwx.  1 mysql mysql  35 Jul 31 14:58 mysql -> mysql-5.7.38-linux-glibc2.12-x86_64
    drwxr-xr-x.  9 mysql mysql 129 Jul 31 14:56 mysql-5.7.38-linux-glibc2.12-x86_64
    drwxr-xr-x.  2 root  root    6 May 19  2020 sbin
    drwxr-xr-x.  5 root  root   49 Jul 19 16:13 share
    drwxr-xr-x.  5 root  root  145 Jul 21 21:19 src
    [root@lnh local]# ls  //编译三部曲已经完成
    apache    bin    include  libexec                              sbin
    apr       etc    lib      mysql                                share
    apr-util  games  lib64    mysql-5.7.38-linux-glibc2.12-x86_64  src
    [root@lnh local]# cd mysql
    [root@lnh mysql]# ls
    bin  docs  include  lib  LICENSE  man  README  share  support-files
    [root@lnh mysql]# echo 'export PATH=$PATH:/usr/local/mysql/bin' > /etc/profile.d/mysql.sh   
    //配置环境变量
    [root@lnh mysql]# source /etc/profile.d/mysql.sh 
    //使环境生效
    [root@lnh mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
    '/usr/include/mysql' -> '/usr/local/mysql/include/'
    //做include的头文件让系统可以识别
    [root@lnh mysql]# chown -R mysql.mysql /usr/include/mysql
    //将软链接的属主属组改成mysql的
    [root@lnh mysql]# ll -d /usr/include/mysql/
    drwxr-xr-x. 3 mysql mysql 4096 Jul 31 14:56 /usr/include/mysql/
    [root@lnh mysql]# vim /etc/ld.so.conf.d/mysql.conf
    [root@lnh mysql]# cat /etc/ld.so.conf.d/mysql.conf
    /usr/local/mysql/lib
    //配置lib
    [root@lnh mysql]# ldconfig 
    //刷新配置
    [root@lnh mysql]# vim /etc/man_db.conf 
    #MANDATORY_MANPATH                      /usr/src/pvm3/man
    #
    MANDATORY_MANPATH                       /usr/man
    MANDATORY_MANPATH                       /usr/share/man
    MANDATORY_MANPATH                       /usr/local/share/man
    MANDATORY_MANPATH                       /usr/local/mysql/man//添加这一行

    创建各实例数据存放的目录

    [root@lnh ~]# mkdir -p /opt/data/{3306,3307,3308}  //创建存放目录
    [root@lnh ~]# chown -R mysql.mysql /opt/data/  
    [root@lnh ~]# ll -d /opt/data/
    drwxr-xr-x. 5 mysql mysql 42 Jul 31 15:24 /opt/data/
    //修改其所属主所属组
    [root@lnh ~]# tree /opt/data/
    /opt/data/
    ├── 3306
    ├── 3307
    └── 3308
    
    3 directories, 0 files
    //查看其结构

    初始化各实例

    [root@lnh ~]# mysqld --initialize --user mysql --datadir /opt/data/3306 //初始化实例   --user指定用户 --datadir指定数据目录
    2022-07-31T07:29:37.154689Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2022-07-31T07:29:37.346729Z 0 [Warning] InnoDB: New log files created, LSN=45790
    2022-07-31T07:29:37.389866Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
    2022-07-31T07:29:37.450981Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 88389665-10a2-11ed-9840-000c2905f428.
    2022-07-31T07:29:37.452192Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
    2022-07-31T07:29:37.758320Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
    2022-07-31T07:29:37.758378Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
    2022-07-31T07:29:37.759177Z 0 [Warning] CA certificate ca.pem is self signed.
    2022-07-31T07:29:37.780720Z 1 [Note] A temporary password is generated for root@localhost: AqldE*a:O8FR
    [root@lnh ~]# echo 'AqldE*a:O8FR' > 3306
    [root@lnh ~]# cat 3306 
    AqldE*a:O8FR
    //将这个格式化的随机密码生成到一个文件里面
    [root@lnh ~]# mysqld --initialize --user mysql --datadir /opt/data/3307   //格式化3307
    2022-07-31T07:33:29.214978Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2022-07-31T07:33:29.491805Z 0 [Warning] InnoDB: New log files created, LSN=45790
    2022-07-31T07:33:29.524728Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
    2022-07-31T07:33:29.598226Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 12977170-10a3-11ed-9d3d-000c2905f428.
    2022-07-31T07:33:29.599323Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
    2022-07-31T07:33:29.932320Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
    2022-07-31T07:33:29.932367Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
    2022-07-31T07:33:29.932766Z 0 [Warning] CA certificate ca.pem is self signed.
    2022-07-31T07:33:30.095306Z 1 [Note] A temporary password is generated for root@localhost: PAJBo+Gxg19I
    [root@lnh ~]# echo ' PAJBo+Gxg19I' > 3307
    [root@lnh ~]# cat 3307 
     PAJBo+Gxg19I
    [root@lnh ~]# mysqld --initialize --user mysql --datadir /opt/data/3308   //格式化3308
    2022-07-31T07:34:23.861697Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2022-07-31T07:34:24.082852Z 0 [Warning] InnoDB: New log files created, LSN=45790
    2022-07-31T07:34:24.112764Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
    2022-07-31T07:34:24.173299Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 331ef070-10a3-11ed-a122-000c2905f428.
    2022-07-31T07:34:24.175009Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
    2022-07-31T07:34:24.374707Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
    2022-07-31T07:34:24.374737Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
    2022-07-31T07:34:24.375103Z 0 [Warning] CA certificate ca.pem is self signed.
    2022-07-31T07:34:24.471521Z 1 [Note] A temporary password is generated for root@localhost: =w&lnU)d-7kK
    [root@lnh ~]# echo ' =w&lnU)d-7kK' > 3308
    [root@lnh ~]# cat 3308
     =w&lnU)d-7kK
    [root@lnh ~]# ls
    3306  3307  3308  anaconda-ks.cfg

    安装perl

    [root@lnh ~]# dnf -y install perl
    Last metadata expiration check: 1:24:50 ago on Sun 31 Jul 2022 02:13:54 PM CST.
    Dependencies resolved.
    ===================================================================================
     Package                      Arch   Version                       Repo       Size
    ===================================================================================
    Installing:
     perl                         x86_64 4:5.26.3-420.el8              AppStream  73 k
    Installing dependencies:
     perl-Algorithm-Diff          noarch 1.1903-9.el8                  base       52 k
     perl-Archive-Tar             noarch 2.30-1.el8                    base       79 k
     perl-Archive-Zip             noarch 1.60-3.el8                    AppStream 108 k
     perl-Attribute-Handlers      noarch 0.99-420.el8                  AppStream  89 k
     perl-B-Debug                 noarch 1.26-2.el8                    AppStream  26 k
     perl-CPAN                    noarch 2.18-397.el8                  AppStream 554 k
     perl-CPAN-Meta               noarch 2.150010-396.el8              AppStream 191 k
     perl-CPAN-Meta-Requirements  noarch 2.140-396.el8                 AppStream  37 k
     perl-CPAN-Meta-YAML          noarch 0.018-397.el8                 AppStream  34 k
     perl-Compress-Bzip2          x86_64 2.26-6.el8                    AppStream  72 k
     perl-Compress-Raw-Bzip2      x86_64 2.081-1.el8                   base       40 k
     perl-Compress-Raw-Zlib       x86_64 2.081-1.el8                   base       68 k
     perl-Config-Perl-V           noarch 0.30-1.el8                    AppStream  22 k
     perl-DB_File                 x86_64 1.842-1.el8                   AppStream  83 k
     perl-Data-OptList            noarch 0.110-6.el8                   AppStream  31 k
     perl-Data-Section            noarch 0.200007-3.el8                AppStream  30 k
     perl-Devel-PPPort            x86_64 3.36-5.el8                    AppStream 118 k
     perl-Devel-Peek              x86_64 1.26-420.el8                  AppStream  94 k
     perl-Devel-SelfStubber       noarch 1.06-420.el8                  AppStream  76 k
     perl-Devel-Size              x86_64 0.81-2.el8                    AppStream  34 k
     perl-Digest-SHA              x86_64 1:6.02-1.el8                  AppStream  66 k
     perl-Encode-devel            x86_64 4:2.97-3.el8                  AppStream  39 k
     perl-Env                     noarch 1.04-395.el8                  AppStream  21 k
     perl-ExtUtils-CBuilder       noarch 1:0.280230-2.el8              AppStream  48 k
     perl-ExtUtils-Command        noarch 1:7.34-1.el8                  AppStream  19 k
     perl-ExtUtils-Embed          noarch 1.34-420.el8                  AppStream  79 k
    ....

    配置配置文件/etc/my.cnf

    [root@lnh ~]# vim /etc/my.cnf
    [root@lnh ~]# cat /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   //pid进程文件
    log-error=/var/log/3306.log   //错误日志
    
    [mysqld3307]
    datadir = /opt/data/3307
    port = 3307
    socket = /tmp/mysql3307.sock
    pid-file = /opt/data/3307/mysql_3307.pid
    log-error=/var/log/3307.log
    
    [mysqld3308]
    datadir = /opt/data/3308
    port = 3308
    socket = /tmp/mysql3308.sock
    pid-file = /opt/data/3308/mysql_3308.pid
    log-error=/var/log/3308.log

    启动各实例

    [root@lnh ~]# mysqld_multi start 3306
    [root@lnh ~]# mysqld_multi start 3307
    [root@lnh ~]# mysqld_multi start 3308
    [root@lnh ~]# ss -antl 
    State    Recv-Q   Send-Q     Local Address:Port      Peer Address:Port   Process   
    LISTEN   0        128              0.0.0.0:22             0.0.0.0:*                
    LISTEN   0        128                 [::]:22                [::]:*                
    LISTEN   0        80                     *:3306                 *:*                
    LISTEN   0        80                     *:3307                 *:*                
    LISTEN   0        80                     *:3308                 *:*            
    //这种方式启动不建议
    [root@lnh ~]# mysqld_multi stop 3308
    [root@lnh ~]# ss -antl 
    State    Recv-Q   Send-Q     Local Address:Port      Peer Address:Port   Process   
    LISTEN   0        128              0.0.0.0:22             0.0.0.0:*                
    LISTEN   0        128                 [::]:22                [::]:*                
    LISTEN   0        80                     *:3306                 *:*                
    LISTEN   0        80                     *:3307                 *:*                
    LISTEN   0        80                     *:3308                 *:*               
    //可以发现这种方式启动程序后关闭不了
    [root@lnh ~]# ps -ef |grep 3306
    root       71742       1  0 15:49 pts/1    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/opt/data/3306 --port=3306 --socket=/tmp/mysql3306.sock --pid-file=/opt/data/3306/mysql_3306.pid --log-error=/var/log/3306.log
    mysql      71878   71742  0 15:49 pts/1    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/opt/data/3306 --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/3306.log --pid-file=/opt/data/3306/mysql_3306.pid --socket=/tmp/mysql3306.sock --port=3306
    root       72257   66880  0 15:53 pts/1    00:00:00 grep --color=auto 3306
    //查看3306进程
    [root@lnh ~]# ps -ef |grep 3306 |grep -v grep
    root       71742       1  0 15:49 pts/1    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/opt/data/3306 --port=3306 --socket=/tmp/mysql3306.sock --pid-file=/opt/data/3306/mysql_3306.pid --log-error=/var/log/3306.log
    mysql      71878   71742  0 15:49 pts/1    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/opt/data/3306 --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/3306.log --pid-file=/opt/data/3306/mysql_3306.pid --socket=/tmp/mysql3306.sock --port=3306
    //取反
    [root@lnh ~]# ps -ef |grep 3306 |grep -v grep |awk '{print$2}'
    71742
    71878
    //取出端口号
    [root@lnh ~]# ps -ef |grep 3306 |grep -v grep |awk '{print$2}'|xargs kill -9   
    //xargs将前面的结果交给后面的来处理
    //杀死了端口号,相当于这个命令可以控制服务停止
    [root@lnh ~]# ps -ef |grep 3307 |grep -v grep |awk '{print$2}'|xargs kill -9
    [root@lnh ~]# ps -ef |grep 3308 |grep -v grep |awk '{print$2}'|xargs kill -9
    [root@lnh ~]# ss -antl
    State    Recv-Q   Send-Q     Local Address:Port      Peer Address:Port   Process   
    LISTEN   0        128              0.0.0.0:22             0.0.0.0:*                
    LISTEN   0        128                 [::]:22                [::]:*                
    //端口号都被杀死

    加入system服务里面

    [root@lnh system]# cd
    [root@lnh ~]# cd /usr/lib/systemd/system
    [root@lnh system]# cp sshd.service 3306.service
    [root@lnh system]# cp sshd.service 3307.service
    [root@lnh system]# cp sshd.service 3308.service
    [root@lnh system]# vim 3306.service 
    [Unit]
    Description=3306 server daemon
    After=network.target sshd-keygen.target
    
    [Service]
    Type=forking
    ExecStart=/usr/local/mysql/bin/mysqld_multi start 3306 //开启的位置
    ExecStop=ps -ef |grep 3306 |grep -v grep |awk '{print$2}'|xargs kill -9   //关闭的命令
    ExecReload=/bin/kill -HUP $MAINPID
    
    [Install]
    WantedBy=multi-user.target
    [root@lnh system]# cp 3306.service 3307.service 
    cp: overwrite '3307.service'? y
    [root@lnh system]# vim 3307.service 
    [Unit]
    Description=3307 server daemon
    After=network.target sshd-keygen.target
    
    [Service]
    Type=forking
    ExecStart=/usr/local/mysql/bin/mysqld_multi start 3307
    ExecStop=ps -ef |grep 3307 |grep -v grep |awk '{print$2}'|xargs kill -9
    ExecReload=/bin/kill -HUP $MAINPID
    
    [Install]
    WantedBy=multi-user.target
    //快捷键 :% s/6/7/g 直接将6变成7
    [root@lnh system]# cp 3306.service 3308.service 
    cp: overwrite '3308.service'? y
    [root@lnh system]# vim 3308.service 
    [Unit]
    Description=3308 server daemon
    After=network.target sshd-keygen.target
    
    [Service]
    Type=forking
    ExecStart=/usr/local/mysql/bin/mysqld_multi start 3308
    ExecStop=ps -ef |grep 3308 |grep -v grep |awk '{print$2}'|xargs kill -9
    ExecReload=/bin/kill -HUP $MAINPID
    
    [Install]
    WantedBy=multi-user.target
    //快捷键 :% s/6/8/g 直接将6变成8
    [root@lnh system]# systemctl daemon-reload 
    //加载一下
    [root@lnh system]# systemctl stop firewalld
    [root@lnh system]# systemctl disable firewalld.service 
    Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
    Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
    [root@lnh system]# vim /etc/selinux/config 
    SELINUX=disabled   //修改
    [root@lnh system]# setenforce 0
    //关闭防火墙
    [root@lnh system]# systemctl start 3306
    [root@lnh system]# systemctl start 3307
    [root@lnh system]# systemctl start 3308
    [root@lnh system]# ss -antl
    State    Recv-Q   Send-Q     Local Address:Port      Peer Address:Port   Process   
    LISTEN   0        128              0.0.0.0:22             0.0.0.0:*                
    LISTEN   0        128                 [::]:22                [::]:*                
    LISTEN   0        80                     *:3306                 *:*                
    LISTEN   0        80                     *:3307                 *:*                
    LISTEN   0        80                     *:3308                 *:*                
    //可以发现全部启动成功
    //如果启动失败就在这个里面journalctl -xe找出错误点

    初始化密码

    [root@lnh ~]# cat 3306
    AqldE*a:O8FR   //查看之前放置的密码
    [root@lnh ~]# mysql -uroot -p'AqldE*a:O8FR' -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 2
    Server version: 5.7.38
    
    Copyright (c) 2000, 2022, Oracle and/or its affiliates.
    
    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('3306');   //修改密码
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> quit
    Bye
    [root@lnh ~]# mysql -uroot -p'3306' -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 3
    Server version: 5.7.38 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2022, Oracle and/or its affiliates.
    
    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> 
    //登录成功
    [root@lnh ~]# cat 3307
     PAJBo+Gxg19I
    [root@lnh ~]# mysql -uroot -p'PAJBo+Gxg19I' -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 3
    Server version: 5.7.38
    
    Copyright (c) 2000, 2022, Oracle and/or its affiliates.
    
    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('3307');   //修改密码
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> quit
    Bye
    [root@lnh ~]# mysql -uroot -p'3307' -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 4
    Server version: 5.7.38 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2022, Oracle and/or its affiliates.
    
    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> 
    //登录成功
    [root@lnh ~]# cat 3308
     =w&lnU)d-7kK
    [root@lnh ~]# mysql -uroot -p'=w&lnU)d-7kK' -S  /tmp/mysql3308.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.38
    
    Copyright (c) 2000, 2022, Oracle and/or its affiliates.
    
    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('3308');   //修改密码
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> quit
    Bye
    [root@lnh ~]# mysql -uroot -p'3308' -S  /tmp/mysql3308.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 3
    Server version: 5.7.38 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2022, Oracle and/or its affiliates.
    
    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> 
    //登录成功

    报错解决

    报错1:
    [root@lnh ~]# mysql -uroot -p'AqldE*a:O8FR'
    mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
    //没有这个包
    解决:
    [root@lnh ~]# dnf provides libncurses.so.5
    Last metadata expiration check: 2:39:05 ago on Sun 31 Jul 2022 02:13:54 PM CST.
    ncurses-compat-libs-6.1-9.20180224.el8.i686 : Ncurses compatibility libraries
    Repo        : base
    Matched from:
    Provide    : libncurses.so.5

    [root@lnh ~]# dnf -y install ncurses-compat-libs-6.1-9.20180224.el8.
    报错2:
    [root@lnh ~]# mysql -uroot -p'AqldE*a:O8FR'
    mysql: [Warning] Using a password on the command line interface can be insecure.
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)   //没有访问到套接字
    解决:[root@lnh ~]# mysql -uroot -p'AqldE*a:O8FR' -S  /tmp/mysql3306.sock 

    本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系bd@zhengruan.com
    作者最新文章
    编程开发 MySQL
    相关文章 更多
    精品专题 更多
    装机必备

    正软商城装机必备专区,精选办公、浏览器、安全防护、影音播放、压缩解压、设计创作和系统工具等电脑常用正版软件,帮助用户快速完成新电脑软件配置。

    Windows

    正软商城Windows软件专区,汇集适用于Windows电脑的办公、设计、安全防护、影音播放、开发工具和系统优化软件,提供软件介绍、系统要求、正版授权及购买下载服务。

    PDF教程

    正软商城PDF教程频道提供PDF编辑、转换、合并、拆分、压缩及格式处理方法,同时介绍常用PDF软件和工具的使用技巧。

    macOS软件

    正软商城macOS软件专区,精选适用于Mac电脑的办公、设计、影音、效率、开发和系统工具,提供软件功能介绍、macOS兼容版本、正版授权及购买下载服务。

    IOS软件

    正软商城iOS软件专区,精选适用于iPhone和iPad的办公、学习、影音、设计、效率及AI应用,提供功能介绍、适用设备、系统要求和正版获取方式等信息。

    AI

    正软商城AI软件专区,汇集AI写作、AI绘画、AI视频、AI办公、AI编程、AI翻译、智能客服和数据分析等人工智能工具,提供功能介绍、适用平台、收费方式及正版购买信息。

    Mac软件 更多
    讯飞智作 网页版
    讯飞智作 网页版

    讯飞智作是一款基于语音合成技术、虚拟人驱动技术与数字人形象声音构建能力的 AI 数字人音视频创作平台。

    火山引擎 网页版
    火山引擎 网页版

    火山引擎是字节跳动旗下企业级云与AI服务平台。聚焦大模型核心能力,依托字节自研豆包多模态大模型,凭借火山方舟一站式平台,提供模型精调、推理部署、智能应用搭建等全链路服务,结合高性能AI算力,助力各行业快速落地大模型数字化与智能化应用。

    Aperty macOS版
    Aperty macOS版

    Aperty 是 Skylum 推出的 AI 人像修图软件,支持自然肤质修饰、瑕疵处理、面部与身体调整、预设及批量同步。

    立刻MV 网页版
    立刻MV 网页版

    立刻MV 面向音乐人、内容创作者和品牌团队,帮助用户低成本完成歌曲 MV、歌词视频、AI 分镜、图生视频与最终合成。

    蛙蛙写作 网页版
    蛙蛙写作 网页版

    蛙蛙写作 AI 创作工具,覆盖小说、剧本、文案,一键生成文稿,打通文字转视频全流程,高效解决创作难题。

    超级简历WonderCV 网页版
    超级简历WonderCV 网页版

    超级简历WonderCV是面向应届生和AI小白的智能求职平台,覆盖简历、面试与职业规划。

    音述AI 网页版
    音述AI 网页版

    音述AI,是一个以“用声音述说故事”为核心的 AI 音乐创作与声音分享社区。

    AionClaw macOS版
    AionClaw macOS版

    AionClaw 是可在桌面端运行的任务型 AI 助手,通过数字专家与技能市场组合办公、创作、数据和开发能力。

    Loomy macOS版
    Loomy macOS版

    Loomy 是科大讯飞推出的桌面 AI 助手,可通过对话、任务与工作目录协助处理办公、内容创作和资料整理。

    AirBuddy 3 macOS版
    AirBuddy 3 macOS版

    AirBuddy 3 是面向 macOS 的蓝牙外设增强工具,可集中查看 AirPods、Beats 与苹果设备电量,提供快速连接、播放控制、电量提醒、桌面小组件和多台 Mac 外设接力等功能。

    AirServer macOS版
    AirServer macOS版

    AirServer macOS版可把 Mac 转换为无线投屏接收端,通过 AirPlay 或 Google Cast 接收手机、平板和电脑画面,并支持多设备同时连接、高清镜像及会话录制,适合家庭娱乐、课堂教学、会议演示和应用展示。

    AnyDesk macOS版
    AnyDesk macOS版

    AnyDesk macOS版是一款适用于远程办公、设备维护和客户支持的远程桌面工具,可连接并操作异地计算机,支持文件传输、无人值守访问、会话权限控制及跨平台协作。

    WINDOWS 更多
    讯飞智作 网页版
    讯飞智作 网页版

    讯飞智作是一款基于语音合成技术、虚拟人驱动技术与数字人形象声音构建能力的 AI 数字人音视频创作平台。

    火山引擎 网页版
    火山引擎 网页版

    火山引擎是字节跳动旗下企业级云与AI服务平台。聚焦大模型核心能力,依托字节自研豆包多模态大模型,凭借火山方舟一站式平台,提供模型精调、推理部署、智能应用搭建等全链路服务,结合高性能AI算力,助力各行业快速落地大模型数字化与智能化应用。

    PixTV 网页版
    PixTV 网页版

    PixTV 是一款在浏览器中使用的 AI 视觉内容创作平台,提供图片、视频、音频、文字生成、AI 分镜、局部重绘、提示词反推和无限画布等工具,适合短剧、漫剧、广告及社交媒体内容制作。

    讯飞绘文 网页版
    讯飞绘文 网页版

    讯飞绘文网页版是科大讯飞推出的AI图文创作与内容运营工具,覆盖热点选题、文章生成、稿件校对、智能配图、排版发布和数据复盘等环节,适合自媒体创作者及内容团队在线使用。

    Maya(Autodesk Maya) Windows版
    Maya(Autodesk Maya) Windows版

    Autodesk Maya 是面向影视、电视、动画和游戏行业的专业三维制作软件,集多边形与 NURBS 建模、角色绑定、关键帧和动作捕捉动画、Bifrost 特效模拟、材质开发及 Arnold 渲染于一体,

    Aperty Windows版
    Aperty Windows版

    Aperty 是 Skylum 推出的 AI 人像修图软件,支持自然肤质修饰、瑕疵处理、面部与身体调整、预设及批量同步。

    立刻MV 网页版
    立刻MV 网页版

    立刻MV 面向音乐人、内容创作者和品牌团队,帮助用户低成本完成歌曲 MV、歌词视频、AI 分镜、图生视频与最终合成。

    蛙蛙写作 网页版
    蛙蛙写作 网页版

    蛙蛙写作 AI 创作工具,覆盖小说、剧本、文案,一键生成文稿,打通文字转视频全流程,高效解决创作难题。

    超级简历WonderCV 网页版
    超级简历WonderCV 网页版

    超级简历WonderCV是面向应届生和AI小白的智能求职平台,覆盖简历、面试与职业规划。

    音述AI 网页版
    音述AI 网页版

    音述AI,是一个以“用声音述说故事”为核心的 AI 音乐创作与声音分享社区。

    AionClaw Windows版
    AionClaw Windows版

    AionClaw 是可在桌面端运行的任务型 AI 助手,通过数字专家与技能市场组合办公、创作、数据和开发能力。

    Loomy Windows版
    Loomy Windows版

    Loomy 是科大讯飞推出的桌面 AI 助手,可通过对话、任务与工作目录协助处理办公、内容创作和资料整理。