色哟哟视频在线观看-色哟哟视频在线-色哟哟欧美15最新在线-色哟哟免费在线观看-国产l精品国产亚洲区在线观看-国产l精品国产亚洲区久久

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

詳解MySQL多實(shí)例部署

馬哥Linux運(yùn)維 ? 來源:博客園 ? 2024-11-11 11:10 ? 次閱讀

目錄

  • mysql多實(shí)例部署
  • 軟件下載
  • 配置用戶并解壓二進(jìn)制程序至/usr/local下
  • 創(chuàng)建各實(shí)例數(shù)據(jù)存放的目錄
  • 初始化各實(shí)例
  • 安裝perl
  • 配置配置文件/etc/my.cnf
  • 啟動各實(shí)例
  • 加入system服務(wù)里面
  • 初始化密碼
  • 報(bào)錯解決

軟件下載

[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                [::]:*                
//驗(yàn)證一下是否有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里面進(jìn)行復(fù)制下載地址
[root@lnh src]# ls
debug  kernels  mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz

配置用戶并解壓二進(jìn)制程序至/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是將結(jié)果打印出來   
'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  //編譯三部曲已經(jīng)完成
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   
//配置環(huán)境變量
[root@lnh mysql]# source /etc/profile.d/mysql.sh 
//使環(huán)境生效
[root@lnh mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
'/usr/include/mysql' -> '/usr/local/mysql/include/'
//做include的頭文件讓系統(tǒng)可以識別
[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//添加這一行

創(chuàng)建各實(shí)例數(shù)據(jù)存放的目錄

[root@lnh ~]# mkdir -p /opt/data/{3306,3307,3308}  //創(chuàng)建存放目錄
[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
//查看其結(jié)構(gòu)

初始化各實(shí)例

[root@lnh ~]# mysqld --initialize --user mysql --datadir /opt/data/3306 //初始化實(shí)例   --user指定用戶 --datadir指定數(shù)據(jù)目錄
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
//將這個格式化的隨機(jī)密碼生成到一個文件里面
[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 //命令執(zhí)行的路徑
mysqladmin = /usr/local/mysql/bin/mysqladmin //命令執(zhí)行的路徑

[mysqld3306]   
datadir = /opt/data/3306   //數(shù)據(jù)目錄
port = 3306  //端口
socket = /tmp/mysql3306.sock  //套接字
pid-file = /opt/data/3306/mysql_3306.pid   //pid進(jìn)程文件
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

啟動各實(shí)例

[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                 *:*               
//可以發(fā)現(xiàn)這種方式啟動程序后關(guān)閉不了
[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進(jìn)程
[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將前面的結(jié)果交給后面的來處理
//殺死了端口號,相當(dāng)于這個命令可以控制服務(wù)停止
[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服務(wù)里面

[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   //關(guān)閉的命令
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
//關(guān)閉防火墻
[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                 *:*                
//可以發(fā)現(xiàn)全部啟動成功
//如果啟動失敗就在這個里面journalctl -xe找出錯誤點(diǎn)

初始化密碼

[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> 
//登錄成功

報(bào)錯解決

報(bào)錯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.
報(bào)錯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 

鏈接:https://www.cnblogs.com/tushanbu/p/16537539.html

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報(bào)投訴
  • 軟件
    +關(guān)注

    關(guān)注

    69

    文章

    4921

    瀏覽量

    87394
  • 程序
    +關(guān)注

    關(guān)注

    117

    文章

    3785

    瀏覽量

    81003
  • MySQL
    +關(guān)注

    關(guān)注

    1

    文章

    804

    瀏覽量

    26528

原文標(biāo)題:一步到位:詳解MySQL多實(shí)例部署,實(shí)現(xiàn)資源高效利用

文章出處:【微信號:magedu-Linux,微信公眾號:馬哥Linux運(yùn)維】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。

收藏 人收藏

    評論

    相關(guān)推薦

    環(huán)路設(shè)計(jì)與實(shí)例詳解

    環(huán)路設(shè)計(jì)與實(shí)例詳解
    發(fā)表于 11-14 08:23

    MySQL root密碼忘記怎么辦?

    mysql.user set password=password('123456') where user='root' and host='localhost';MySQL實(shí)例1
    發(fā)表于 06-22 17:54

    概述Mysql的分區(qū)

    Mysql的分區(qū)詳解
    發(fā)表于 07-15 17:10

    Protel DXP 實(shí)例教程詳解

    Protel DXP 實(shí)例教程詳解Protel DXP 實(shí)例教程詳解下載介紹:Protel DXP 多媒體實(shí)例教程
    發(fā)表于 03-12 02:12 ?0次下載

    ARMCortex-M3應(yīng)用開發(fā)實(shí)例詳解

    ARMCortex-M3應(yīng)用開發(fā)實(shí)例詳解(例程)
    發(fā)表于 06-06 17:01 ?66次下載

    MATLAB通信仿真及應(yīng)用實(shí)例詳解

    通信系統(tǒng)的仿真和實(shí)例詳解,非常詳細(xì)的程序內(nèi)容
    發(fā)表于 07-13 17:43 ?15次下載

    Linux網(wǎng)絡(luò)編程實(shí)例詳解

    網(wǎng)絡(luò)通訊教程學(xué)習(xí)之Linux網(wǎng)絡(luò)編程實(shí)例詳解
    發(fā)表于 09-01 14:55 ?0次下載

    基于MATLAB通信仿真及應(yīng)用實(shí)例詳解

    基于MATLAB通信仿真及應(yīng)用實(shí)例詳解
    發(fā)表于 09-04 09:01 ?49次下載
    基于MATLAB通信仿真及應(yīng)用<b class='flag-5'>實(shí)例</b><b class='flag-5'>詳解</b>

    The MySQL C API 編程實(shí)例

    在網(wǎng)上找了一些MYSQL C API編程的文章,如《The MySQL C API 編程實(shí)例》,看了后覺得還是寫的不夠充分,根據(jù)自己經(jīng)驗(yàn)又?jǐn)U充了一些知識,希望對需要調(diào)用到MYSQL的C
    發(fā)表于 04-13 15:01 ?5次下載

    理解MySQL體系結(jié)構(gòu)的數(shù)據(jù)庫和實(shí)例

    在面試中經(jīng)常會問MySQL的體系結(jié)構(gòu),接下來詳細(xì)分析MySQL的體系結(jié)構(gòu)之前先理解數(shù)據(jù)庫和實(shí)例兩個概念。
    的頭像 發(fā)表于 05-03 17:28 ?2250次閱讀

    python經(jīng)典實(shí)例詳解

    python經(jīng)典實(shí)例詳解說明。
    發(fā)表于 04-26 10:14 ?32次下載

    mysql部署在k8s上的實(shí)現(xiàn)方案

    的 RDBMS (Relational Database Management System,關(guān)系數(shù)據(jù)庫管理系統(tǒng)) 應(yīng)用軟件之一。這里主要講 mysql 部署在 k8s 上,mysql 部署
    的頭像 發(fā)表于 09-26 10:39 ?2506次閱讀

    LabVIEW操作MySQL數(shù)據(jù)庫編程實(shí)例

    LabVIEW操作MySQL數(shù)據(jù)庫編程實(shí)例
    發(fā)表于 10-13 15:05 ?48次下載

    docker部署mysql的壞處

    Docker 是一種虛擬化技術(shù),它允許開發(fā)人員在容器內(nèi)打包應(yīng)用程序及其所有依賴項(xiàng),從而實(shí)現(xiàn)在不同環(huán)境中運(yùn)行相同的應(yīng)用程序的能力。然而,在使用 Docker 部署 MySQL 時(shí),也存在一些潛在
    的頭像 發(fā)表于 11-23 09:29 ?1404次閱讀

    香港云服務(wù)器怎么部署MySQL數(shù)據(jù)庫?

    在香港云服務(wù)器上部署MySQL數(shù)據(jù)庫的步驟如下: 步驟 1: 更新軟件包列表 首先,確保軟件包列表是最新的。在終端中執(zhí)行以下命令: sudo apt update 步驟 2: 安裝 MySQL
    的頭像 發(fā)表于 11-14 16:15 ?159次閱讀
    主站蜘蛛池模板: 俄罗斯美女性生活| 免费国产综合视频在线看| chinese东北老年tv视频| 丫鬟粗大狠狠贯穿h| 美女张开让男生桶| 国产亚洲精品久久久久久线投注| 92精品国产成人观看免费| 午夜影院和视费x看| 青青草原国产在线观看| 久久精品热线免费| 国产精品久久人妻互换毛片| 99视频网站| 折磨比基尼美女挠肚子| 亚洲AV噜噜88| 特级毛片内射WWW无码| 欧美成人无码视频午夜福利| 久久九九亚洲精品| 国产亚洲精品久久久久久鸭绿欲| RUN AWAY无删减全集动漫| 综合色就爱涩涩涩综合婷婷 | 一区精品在线| 午夜伦理yy44008影院| 日本三级按摩推拿按摩| 免费在线亚洲视频| 久久精品一区二区免费看| 国产一卡2卡3卡4卡孕妇网站| 动漫美女无衣| 宝贝乖女好紧好深好爽老师| 99精品久久| 最近2019中文字幕免费版视频| 亚洲午夜精品AV无码少妇| 思思99精品国产自在现线| 日韩一区二区三区精品| 任你躁国语自产二区在线播放| 女人色极品影院| 男女AA片免费| 免费 高清 中文在线观看| 沦为公交两奶头春药高潮迭起| 久久足恋网| 美女脱衣服搞鸡| 奶大B紧17p|