mysql多实例部署

该文描述了在Linux环境下安装MySQL的详细步骤,包括下载软件包、创建用户和组、解压到指定目录、设置目录权限、配置环境变量、初始化多个实例、安装依赖、设置开机自启等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

进入/usr/src/目录

[root@xk ~]# cd /usr/src/

把下载好的mysql-5.7.40-linux-glibc2.12-x86_64.tar.gz的包通过xshellwen文件传输移动到/usr/src下

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

//创建用户和组
[root@xk src]# groupadd -r mysql
[root@xk src]# useradd -M -s /sbin/nologin -g mysql mysql

将mysql的软件包解压至/usr/local

[root@xk src]# tar xf mysql-5.7.40-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@xk src]# ls /usr/local/
apache    lib
apr       lib64
apr-util  libexec
bin       mysql-5.7.40-linux-glibc2.12-x86_64
etc       sbin
games     share
include   src
[root@xk src]# cd /usr/local/
[root@xk local]# ln -sv mysql-5.7.40-linux-glibc2.12-x86_64/ mysql
'mysql' -> 'mysql-5.7.40-linux-glibc2.12-x86_64/'
[root@xk local]# ll
total 0
drwxr-xr-x. 14 root root 164 Dec 26 23:41 apache
drwxr-xr-x.  6 root root  58 Dec 26 23:36 apr
drwxr-xr-x.  5 root root  43 Dec 26 23:37 apr-util
drwxr-xr-x.  2 root root   6 Jun 22  2021 bin
drwxr-xr-x.  2 root root   6 Jun 22  2021 etc
drwxr-xr-x.  2 root root   6 Jun 22  2021 games
drwxr-xr-x.  2 root root   6 Jun 22  2021 include
drwxr-xr-x.  2 root root   6 Jun 22  2021 lib
drwxr-xr-x.  3 root root  17 Dec 23 00:17 lib64
drwxr-xr-x.  2 root root   6 Jun 22  2021 libexec
lrwxrwxrwx   1 root root  36 Feb 16 10:11 mysql -> mysql-5.7.40-linux-glibc2.12-x86_64/
drwxr-xr-x   9 root root 129 Feb 16 10:09 mysql-5.7.40-linux-glibc2.12-x86_64
drwxr-xr-x.  2 root root   6 Jun 22  2021 sbin
drwxr-xr-x.  5 root root  49 Dec 23 00:17 share
drwxr-xr-x.  2 root root   6 Jun 22  2021 src

//修改目录/usr/local/mysql的属主属组

[root@xk local]# chown -R mysql.mysql /usr/local/mysql
[root@xk local]# ll /usr/local/mysql -d
lrwxrwxrwx 1 mysql mysql 36 Feb 16 10:11 /usr/local/mysql -> mysql-5.7.40-linux-glibc2.12-x86_64/

//配置环境变量

[root@xk local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@xk local]# . /etc/profile.d/mysql.sh
[root@xk local]# echo $PATH
/usr/local/mysql/bin:/usr/local/apache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

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

[root@xk mysql]# mkdir -p /opt/data/{3306,3307,33
08}
[root@xk mysql]# ls /opt/data
3306  3307  3308
[root@xk mysql]# chown -R mysql.mysql /opt/data/
[root@xk mysql]# ll /opt/data/
total 0
drwxr-xr-x 2 mysql mysql 6 Feb 16 14:02 3306
drwxr-xr-x 2 mysql mysql 6 Feb 16 14:02 3307
drwxr-xr-x 2 mysql mysql 6 Feb 16 14:02 3308
[root@xk mysql]# tree /opt/data/                 ///// 注释:此时发现系统没有tree命令
-bash: tree: command not found
[root@xk mysql]# tree /opt/data/ /opt/data/
-bash: tree: command not found
[root@xk mysql]# yum -y install tree             ///// 注释:使用yum 安装tree
Last metadata expiration check: 3:11:23 ago on Thu 16 Feb 2023 10:53:42 AM CST.
Dependencies resolved.
=================================================
 Package
        Arch     Version          Repo      Size
=================================================
Installing:
 tree   x86_64   1.7.0-15.el8     baseos    59 k

Transaction Summary
=================================================
Install  1 Package

Total download size: 59 k
Installed size: 109 k
Downloading Packages:
tree-1.7.0-15.el  40 kB/s |  59 kB     00:01    
-------------------------------------------------
Total             40 kB/s |  59 kB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                         1/1 
  Installing       : tree-1.7.0-15.el8.x86   1/1 
  Running scriptlet: tree-1.7.0-15.el8.x86   1/1 
  Verifying        : tree-1.7.0-15.el8.x86   1/1 

Installed:
  tree-1.7.0-15.el8.x86_64                       

Complete!
[root@xk mysql]# tree /opt/data/
/opt/data/
├── 3306
├── 3307
└── 3308

3 directories, 0 files

初始化{3306,3307,3308}实例

初始化3306实例
[root@xk ~]# mysqld --initialize --datadir=/opt/data/3306 --user=mysql
2023-02-16T07:44:40.303599Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-02-16T07:44:40.568966Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-02-16T07:44:40.614325Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-02-16T07:44:40.678257Z 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: c534220d-adcd-11ed-964c-000c295105b0.
2023-02-16T07:44:40.679271Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-02-16T07:44:41.090391Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-02-16T07:44:41.090424Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-02-16T07:44:41.090863Z 0 [Warning] CA certificate ca.pem is self signed.
2023-02-16T07:44:41.134351Z 1 [Note] A temporary password is generated for root@localhost: Qk4FiX?k##*s

[root@xk ~]# echo 'Qk4FiX?k##*s' > 3306_pass

初始化3307实例
[root@xk ~]# mysqld --initialize --datadir=/opt/data/3307 --user=mysql
2023-02-16T07:47:14.816010Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-02-16T07:47:14.976237Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-02-16T07:47:15.013629Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-02-16T07:47:15.068635Z 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: 213a3c30-adce-11ed-9a92-000c295105b0.
2023-02-16T07:47:15.069536Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-02-16T07:47:15.356160Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-02-16T07:47:15.356190Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-02-16T07:47:15.356631Z 0 [Warning] CA certificate ca.pem is self signed.
2023-02-16T07:47:15.508414Z 1 [Note] A temporary password is generated for root@localhost: hqI<ecimK4%d
[root@xk ~]# echo 'hqI<ecimK4%d' > 3307_pass

初始化3308实例
[root@xk ~]# mysqld --initialize --datadir=/opt/data/3308 --user=mysql
2023-02-16T07:49:15.076345Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-02-16T07:49:15.312257Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-02-16T07:49:15.348357Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-02-16T07:49:15.353296Z 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: 68ec37d3-adce-11ed-9f4e-000c295105b0.
2023-02-16T07:49:15.353831Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-02-16T07:49:15.921746Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2023-02-16T07:49:15.921784Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2023-02-16T07:49:15.922252Z 0 [Warning] CA certificate ca.pem is self signed.
2023-02-16T07:49:15.945522Z 1 [Note] A temporary password is generated for root@localhost: OuO,Uajt7(Q=
[root@xk ~]# echo 'OuO,Uajt7(Q=' > 3308_pass

安装perl

[root@xk ~]# yum -y install peal
Last metadata expiration check: 0:30:55 ago on Thu 16 Feb 2023 03:19:43 PM CST.
No match for argument: peal
Error: Unable to find a match: peal
[root@xk ~]# yum -y install perl
Last metadata expiration check: 0:32:24 ago on Thu 16 Feb 2023 03:19:43 PM CST.
Dependencies resolved.
=================================================
 Package
       Arch   Version            Repo       Size
=================================================
Installing:
 perl  x86_64 4:5.26.3-420.el8   appstream  73 k
Installing dependencies:
 annobin
       x86_64 9.72-1.el8_5.2     appstream 111 k
 dwz   x86_64 0.12-10.el8        appstream 109 k
 efi-srpm-macros
       noarch 3-3.el8            appstream  22 k
 ghc-srpm-macros
       noarch 1.4.2-7.el8        appstream 9.3 k
 go-srpm-macros
       noarch 2-17.el8           appstream  13 k
 ocaml-srpm-macros
       noarch 5-4.el8            appstream 9.4 k
 openblas-srpm-macros
       noarch 2-2.el8            appstream 7.9 k
 perl-Algorithm-Diff
       noarch 1.1903-9.el8       baseos     52 k
 perl-Archive-Tar
       noarch 2.30-1.el8         baseos     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        baseos     40 k
 perl-Compress-Raw-Zlib
       x86_64 2.081-1.el8        baseos     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
 perl-ExtUtils-Install
       noarch 2.14-4.el8         appstream  46 k
 perl-ExtUtils-MM-Utils
       noarch 1:7.34-1.el8       appstream  17 k
 perl-ExtUtils-MakeMaker
       noarch 1:7.34-1.el8       appstream 300 k
 perl-ExtUtils-Manifest
       noarch 1.70-395.el8       appstream  37 k
 perl-ExtUtils-Miniperl
       noarch 1.06-420.el8       appstream  76 k
**省略安装细节过于漫长
 ............................ 
  zip-3.0-23.el8.x86_64                          

Complete!

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

[root@xk ~]# 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_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

启动3306,3307,3308

[root@xk ~]# mysqld_multi start 3306
[root@xk ~]# mysqld_multi start 3307
[root@xk ~]# mysqld_multi start 3308
[root@xk ~]# ss -antl
State    Recv-Q   Send-Q     Local Address:Port           Peer Address:Port        Process        
LISTEN   0        128              0.0.0.0:111                 0.0.0.0:*                          
LISTEN   0        128              0.0.0.0:22                  0.0.0.0:*                          
LISTEN   0        128                 [::]:111                    [::]:*                          
LISTEN   0        128                    *:80                        *:*                          
LISTEN   0        128                 [::]:22                     [::]:*                          
LISTEN   0        80                     *:3306                      *:*                          
LISTEN   0        80                     *:3307                      *:*                          
LISTEN   0        80                     *:3308                      *:*                          

初始化{3306,3307,3308}密码,并重新设置

[root@xk ~]# cat 3306_pass 
Qk4FiX?k##*s
[root@xk ~]# mysql -uroot -p 'Qk4FiX?k##*s' -S /tmp/mysql3306.sock
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

此处发现报错,查询需要哪些包

[root@xk ~]# yum -y install provides
Last metadata expiration check: 0:42:27 ago on Thu 16 Feb 2023 03:19:43 PM CST.
No match for argument: provides
Error: Unable to find a match: provides
[root@xk ~]# yum -y install provides libncurses.so.5
Last metadata expiration check: 0:43:12 ago on Thu 16 Feb 2023 03:19:43 PM CST.
No match for argument: provides
Error: Unable to find a match: provides
[root@xk ~]# yum provides libncurses.so.5
Last metadata expiration check: 0:45:25 ago on Thu 16 Feb 2023 03:19:43 PM CST.
ncurses-compat-libs-6.1-9.20180224.el8.i686 :
     ...: Ncurses compatibility libraries
Repo        : baseos
Matched from:
Provide    : libncurses.so.5
[root@xk ~]# yum -y install ncurses-compat-libs-6.1-9.20180224.el8.i686
Last metadata expiration check: 0:50:38 ago on Thu 16 Feb 2023 03:19:43 PM CST.
Dependencies resolved.
=================================================
 Package    Arch Version            Repo    Size
=================================================
Installing:
 ncurses-compat-libs
            i686 6.1-9.20180224.el8 baseos 347 k
Installing dependencies:
 glibc      i686 2.28-164.el8       baseos 3.4 M
 libgcc     i686 8.5.0-4.el8_5      baseos  87 k
 libstdc++  i686 8.5.0-4.el8_5      baseos 489 k

Transaction Summary
=================================================
Install  4 Packages

Total download size: 4.3 M
Installed size: 16 M
Downloading Packages:
(1/4): libgcc-8.  59 kB/s |  87 kB     00:01    
(2/4): libstdc++ 244 kB/s | 489 kB     00:02    
(3/4): glibc-2.2 1.3 MB/s | 3.4 MB     00:02    
(4/4): ncurses-c 209 kB/s | 347 kB     00:01    
-------------------------------------------------
Total            1.4 MB/s | 4.3 MB     00:03     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                         1/1 
  Installing       : libgcc-8.5.0-4.el8_5.   1/4 
  Running scriptlet: libgcc-8.5.0-4.el8_5.   1/4 
  Running scriptlet: glibc-2.28-164.el8.i6   2/4 
  Installing       : glibc-2.28-164.el8.i6   2/4 
  Running scriptlet: glibc-2.28-164.el8.i6   2/4 
  Installing       : libstdc++-8.5.0-4.el8   3/4 
  Running scriptlet: libstdc++-8.5.0-4.el8   3/4 
  Installing       : ncurses-compat-libs-6   4/4 
  Running scriptlet: ncurses-compat-libs-6   4/4 
  Verifying        : glibc-2.28-164.el8.i6   1/4 
  Verifying        : libgcc-8.5.0-4.el8_5.   2/4 
  Verifying        : libstdc++-8.5.0-4.el8   3/4 
  Verifying        : ncurses-compat-libs-6   4/4 

Installed:
  glibc-2.28-164.el8.i686                        
  libgcc-8.5.0-4.el8_5.i686                      
  libstdc++-8.5.0-4.el8_5.i686                   
  ncurses-compat-libs-6.1-9.20180224.el8.i686    

Complete!
[root@xk ~]# yum install libncurses*
Last metadata expiration check: 1:02:47 ago on Thu 16 Feb 2023 03:19:43 PM CST.
Package ncurses-compat-libs-6.1-9.20180224.el8.i686 is already installed.
Package ncurses-libs-6.1-9.20180224.el8.x86_64 is already installed.
Dependencies resolved.
=================================================
 Package  Arch   Version            Repo    Size
=================================================
Installing:
 ncurses-c++-libs
          x86_64 6.1-9.20180224.el8 baseos  58 k
 ncurses-compat-libs
          x86_64 6.1-9.20180224.el8 baseos 328 k

Transaction Summary
=================================================
Install  2 Packages

Total download size: 386 k
Installed size: 1.1 M
Is this ok [y/N]: yes
Downloading Packages:
(1/2): ncurses-c  42 kB/s |  58 kB     00:01    
(2/2): ncurses-c 185 kB/s | 328 kB     00:01    
-------------------------------------------------
Total            218 kB/s | 386 kB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                         1/1 
  Installing       : ncurses-compat-libs-6   1/2 
  Installing       : ncurses-c++-libs-6.1-   2/2 
  Running scriptlet: ncurses-c++-libs-6.1-   2/2 
  Verifying        : ncurses-c++-libs-6.1-   1/2 
  Verifying        : ncurses-compat-libs-6   2/2 

Installed:
  ncurses-c++-libs-6.1-9.20180224.el8.x86_64     
  ncurses-compat-libs-6.1-9.20180224.el8.x86_64  

Complete!

初始化{3306,3307,3308}密码,并重新设置密码为rain time23

[root@xk ~]# mysql -uroot -p'Qk4FiX?k##*s' -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 4
Server version: 5.7.40

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('raintime123');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit
Bye
[root@xk ~]# cat 3307_pass 
hqI<ecimK4%d
[root@xk ~]# mysql -uroot -p'hqI<ecimK4%d' -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.40

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('raintime123');
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> quit
Bye
[root@xk ~]# cat 3308_pass 
OuO,Uajt7(Q=
[root@xk ~]# mysql -uroot -p'OuO,Uajt7(Q=' -S /tmp/mysql3307.sock
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@xk ~]# mysql -uroot -p'OuO,Uajt7(Q=' -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.40

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('raintime123');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit
Bye

设置开机自启,启动3306,3307,3308实例的服务

[root@xk ~]# cp /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/my3306.service
[root@xk ~]# vim /usr/lib/systemd/system/my3306.service
[root@xk ~]# cat /usr/lib/systemd/system/my3306.service
[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target sshd-keygen.target
Wants=sshd-keygen.target

[Service]
Type=notify
EnvironmentFile=-/etc/crypto-policies/back-ends/opensshserver.config
EnvironmentFile=-/etc/sysconfig/sshd
ExecStart=/usr/sbin/sshd -D $OPTIONS $CRYPTO_POLICY
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target
[root@xk ~]# vim /usr/lib/systemd/system/my3306.service
[root@xk ~]# vim /usr/lib/systemd/system/my3306.service
[root@xk ~]# vim /usr/lib/systemd/system/my3307.service
[root@xk ~]# vim /usr/lib/systemd/system/my3308.service
[root@xk ~]# ln -s /usr/local/mysql/bin/my_print_defaults /usr/bin/
[root@xk ~]# systemctl enable my3306
Created symlink /etc/systemd/system/multi-user.target.wants/my3306.service → /usr/lib/systemd/system/my3306.service.
[root@xk ~]# systemctl start my3306
[root@xk ~]# systemctl status my3306
● my3306.service - 3306 server daemon
   Loaded: loaded (/usr/lib/systemd/system/my330>
   Active: failed (Result: exit-code) since Thu >
  Process: 20946 ExecStart=/usr/local/mysql/bin/>
 Main PID: 20951 (code=exited, status=1/FAILURE)

Feb 16 16:37:53 xk systemd[1]: Starting 3306 ser>
Feb 16 16:37:53 xk systemd[1]: Started 3306 serv>
Feb 16 16:37:53 xk systemd[1]: my3306.service: M>
Feb 16 16:37:53 xk systemd[1]: my3306.service: F>

[root@xk ~]# reboot 
Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(10.0.0.129) at 16:38:26.

Type `help' to learn how to use Xshell prompt.
[C:\~]$ 

Connecting to 10.0.0.129:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

WARNING! The remote SSH server rejected X11 forwarding request.
Last login: Thu Feb 16 16:39:03 2023
[root@xk ~]# systemctl enable my3306
[root@xk ~]# systemctl start my3306
[root@xk ~]# systemctl status my3306
● my3306.service - 3306 server daemon
   Loaded: loaded (/usr/lib/systemd/system/my330>
   Active: active (running) since Thu 2023-02-16>
 Main PID: 957 (mysqld_safe)
    Tasks: 28 (limit: 5803)
   Memory: 223.5M
   CGroup: /system.slice/my3306.service
           ├─ 957 /bin/sh /usr/local/mysql/bin/m>
           └─1140 /usr/local/mysql/bin/mysqld -->

Feb 16 16:38:46 xk systemd[1]: Starting 3306 ser>
Feb 16 16:38:46 xk systemd[1]: Started 3306 serv>

[root@xk ~]# cd /usr/lib/systemd/system
[root@xk system]# cp my3306.service my3307.service
cp: overwrite 'my3307.service'? yes
[root@xk system]# cp my3306.service my3308.service
cp: overwrite 'my3308.service'? yes      
[root@xk system]# vim my3307.service
[root@xk system]# vim my3308.service
[root@xk system]# systemctl enable my3307.serviceCreated symlink /etc/systemd/system/multi-user.target.wants/my3307.service → /usr/lib/systemd/system/my3307.service.
[root@xk system]# systemctl enable my3308.service 
Created symlink /etc/systemd/system/multi-user.target.wants/my3308.service → /usr/lib/systemd/system/my3308.service.
[root@xk system]# systemctl start my3307
[root@xk system]# systemctl start my3308
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值