mysql數據備份與恢復和mysql多實例部署

来源:https://www.cnblogs.com/marymary/archive/2022/07/31/16537774.html
-Advertisement-
Play Games

1.mysql資料庫備份與恢復 1.1 資料庫常用備份方案 資料庫備份方案: 冷備份:先把資料庫服務停掉,然後拷貝資料庫目錄下的文件進行備份 物理備份 溫備份: 熱備份:資料庫服務正常運行情況,直接對資料庫進行備份 全量備份:全部備份 增量備份:第一次全備,第二次在第一次全備更改的基礎上備份 差異備 ...


目錄

1.mysql資料庫備份與恢復

1.1 資料庫常用備份方案

資料庫備份方案:

  • 冷備份:先把資料庫服務停掉,然後拷貝資料庫目錄下的文件進行備份 物理備份
  • 溫備份:
  • 熱備份:資料庫服務正常運行情況,直接對資料庫進行備份
    • 全量備份:全部備份
    • 增量備份:第一次全備,第二次在第一次全備更改的基礎上備份
    • 差異備份:全部備份,差異備份-->全備
備份方案 特點
全量備份 全量備份就是指對某一個時間點上的所有數據或應用進行的一個完全拷貝。數據恢復快。備份時間長
增量備份 增量備份是指在一次全備份或上一次增量備份後,以後每次的備份只需備份與前一次相比增加和者被修改的文件。這就意味著,第一次增量備份的對象是進行全備後所產生的增加和修改的文件;第二次增量備份的對象是進行第一次增量備份後所產生的增加和修改的文件,如此類推。沒有重覆的備份數據,備份時間短,恢複數據時必須按一定的順序進行
差異備份 備份上一次的完全備份後發生變化的所有文件。差異備份是指在一次全備份後到進行差異備份的這段時間內,對那些增加或者修改文件的備份。在進行恢復時,我們只需對第一次全量備份和最後一次差異備份進行恢復。

1.2 mysql備份工具mysqldump

//語法:
mysqldump [OPTIONS] database [tables ...]//備份表(多表之間用空格連接)
mysqldump [OPTIONS] --all-databases [OPTIONS]//全備
mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]//備份指定的資料庫

//常用的OPTIONS:
-uUSERNAME //指定資料庫用戶名
-hHOST //指定伺服器主機,請使用ip地址
-pPASSWORD //指定資料庫用戶的密碼
-P# //指定資料庫監聽的埠,這裡的#需用實際的埠號代替,如-P3307

[[email protected] ~]# mysqldump -uroot -pmarui runtime tb_course > tb_course-$(date '+%Y%m%d%H%M%S').sql  (備份表)
mysqldump: [Warning] Using a password on the command line interface can be insecure.
[[email protected] ~]# ls

tb_course-20220731140014.sql

[[email protected] ~]# vim .my.cnf(免密登錄)
[mysqldump]
user=root
password=marui
(實現免密登錄)
[[email protected] ~]# mysqldump runtime tb_course > tb_course-$(date '+%Y%m%d%H%M%S').sql
[[email protected] ~]# ls

tb_course-20220731140014.sql
tb_course-20220731140726.sql

[[email protected] ~]# mysqldump --databases runtime > runtime-$(date '+%Y%m%d%H%M%S').sql(備份資料庫)
[[email protected] ~]# ls

runtime-20220731141008.sql

[[email protected] ~]# mysqldump --all-databases > all-$(date '+%Y%m%d%H%M%S').sql(全備)
[[email protected] ~]# ls

all-20220731141206.sql

[[email protected] ~]# 

1.3 mysql數據恢復

mysql> delete from tb_course where id = 5 or id = 6;(刪除數據)
Query OK, 2 rows affected (0.01 sec)

mysql> select * from tb_course;
+----+-------------+
| id | course_name |
+----+-------------+
|  1 | Java        |
|  2 | Mysql       |
|  3 | Python      |
|  4 | Go          |
+----+-------------+
4 rows in set (0.00 sec)

mysql> 
[[email protected] ~]# vim .my.cnf
[mysqldump]
user=root
password=marui

[client]
user=root
password=marui
方法一:
[[email protected] ~]# mysql runtime < tb_course-20220731140726.sql

mysql> show tables;
+-------------------+
| Tables_in_runtime |
+-------------------+
| tb_course         |
| tb_students_info  |
+-------------------+
2 rows in set (0.00 sec)

mysql> select * from tb_course;
+----+-------------+
| id | course_name |
+----+-------------+
|  1 | Java        |
|  2 | Mysql       |
|  3 | Python      |
|  4 | Go          |
|  5 | C++         |
|  6 | HTML        |
+----+-------------+
6 rows in set (0.00 sec)

mysql> 
方法二:
mysql> source tb_course-20220731140726.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

......

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> select * from tb_course;
+----+-------------+
| id | course_name |
+----+-------------+
|  1 | Java        |
|  2 | Mysql       |
|  3 | Python      |
|  4 | Go          |
|  5 | C++         |
|  6 | HTML        |
+----+-------------+
6 rows in set (0.00 sec)

mysql> 

物理備份
[[email protected] ~]# cd /opt/data/
[[email protected] data]# ls
auto.cnf         client-key.pem  ib_logfile1  mysql_bin.000003  performance_schema  server-cert.pem
ca-key.pem       ib_buffer_pool  ibtmp1       mysql_bin.000004  private_key.pem     server-key.pem
ca.pem           ibdata1         mr.err       mysql_bin.index   public_key.pem      sys
client-cert.pem  ib_logfile0     mysql        mysql.pid         runtime
[[email protected] data]# mkdir /opt/mysql_bak/
[[email protected] data]# mv * /opt/mysql_bak/
[[email protected] data]# ls
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)

mysql> 
[[email protected] data]# mv /opt/mysql_bak/* .
[[email protected] data]# ls
auto.cnf         client-key.pem  ib_logfile1  mysql_bin.000003  performance_schema  server-cert.pem
ca-key.pem       ib_buffer_pool  ibtmp1       mysql_bin.000004  private_key.pem     server-key.pem
ca.pem           ibdata1         mr.err       mysql_bin.index   public_key.pem      sys
client-cert.pem  ib_logfile0     mysql        mysql.pid         runtime
[[email protected] data]#
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| runtime            |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> 


1.4 差異備份

[[email protected] ~]# vim /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
sql-mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
server-id=10
log-bin=mysql_bin
[[email protected] ~]# systemctl restart mysqld
[[email protected] ~]# mysqldump --single-transaction --flush-logs --master-data=2 --all-databases --delete-master-logs > all.chayi.sql
(--single-transaction是事務日誌,--flush-logs是刷新日誌,--master-data=2指定master標誌符,--delete-master-logs刪除主的日誌)
[[email protected] ~]# ls

all.chayi.sql

[[email protected] ~]# 
mysql> insert tb_course(course_name) values('English'),('math');
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> delete from tb_course where id = 4;
Query OK, 1 row affected (0.00 sec)

mysql> select * from tb_course;
+----+-------------+
| id | course_name |
+----+-------------+
|  1 | Java        |
|  2 | Mysql       |
|  3 | Python      |
|  5 | C++         |
|  6 | HTML        |
|  7 | English     |
|  8 | math        |
+----+-------------+
7 rows in set (0.00 sec)

mysql> 
刷新二進位日誌
[[email protected] ~]# ll /opt/data/
total 123060

-rw-r-----. 1 mysql mysql      713 Jul 31 16:04 mysql_bin.000003
-rw-r-----. 1 mysql mysql       19 Jul 31 15:59 mysql_bin.index

drwxr-x---. 2 mysql mysql     8192 Jul 27 16:21 sys
[[email protected] ~]# cat /opt/data/mysql_bin.index 
./mysql_bin.000003
[[email protected] ~]# mysqladmin -uroot -pmarui flush-logs
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
[[email protected] ~]# ll /opt/data/
total 123064

drwxr-x---. 2 mysql mysql     4096 Jul 27 16:21 mysql
-rw-r-----. 1 mysql mysql      760 Jul 31 16:09 mysql_bin.000003
-rw-r-----. 1 mysql mysql      154 Jul 31 16:09 mysql_bin.000004
-rw-r-----. 1 mysql mysql       38 Jul 31 16:09 mysql_bin.index

[ro[email protected] ~]# cat /opt/data/mysql_bin.index 
./mysql_bin.000003
./mysql_bin.000004
[[email protected] ~]# 
[[email protected] ~]# mysql < all.chayi.sql
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| runtime            |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> use runtime;
Database changed
mysql> select * from tb_course;
+----+-------------+
| id | course_name |
+----+-------------+
|  1 | Java        |
|  2 | Mysql       |
|  3 | Python      |
|  4 | Go          |
|  5 | C++         |
|  6 | HTML        |
+----+-------------+
6 rows in set (0.00 sec)

mysql> 
mysql> show binlog events in 'mysql_bin.000003';
+------------------+-----+----------------+-----------+-------------+---------------------------------------+
| Log_name         | Pos | Event_type     | Server_id | End_log_pos | Info                                  |
+------------------+-----+----------------+-----------+-------------+---------------------------------------+
| mysql_bin.000003 |   4 | Format_desc    |        10 |         123 | Server ver: 5.7.38-log, Binlog ver: 4 |
| mysql_bin.000003 | 123 | Previous_gtids |        10 |         154 |                                       |
| mysql_bin.000003 | 154 | Anonymous_Gtid |        10 |         219 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'  |
| mysql_bin.000003 | 219 | Query          |        10 |         294 | BEGIN                                 |
| mysql_bin.000003 | 294 | Table_map      |        10 |         352 | table_id: 140 (runtime.tb_course)     |
| mysql_bin.000003 | 352 | Write_rows     |        10 |         410 | table_id: 140 flags: STMT_END_F       |
| mysql_bin.000003 | 410 | Xid            |        10 |         441 | COMMIT /* xid=480 */                  |
| mysql_bin.000003 | 441 | Anonymous_Gtid |        10 |         506 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'  |
| mysql_bin.000003 | 506 | Query          |        10 |         581 | BEGIN                                 |
| mysql_bin.000003 | 581 | Table_map      |        10 |         639 | table_id: 140 (runtime.tb_course)     |
| mysql_bin.000003 | 639 | Delete_rows    |        10 |         682 | table_id: 140 flags: STMT_END_F       |
| mysql_bin.000003 | 682 | Xid            |        10 |         713 | COMMIT /* xid=482 */                  |
| mysql_bin.000003 | 713 | Rotate         |        10 |         760 | mysql_bin.000004;pos=4                |
+------------------+-----+----------------+-----------+-------------+---------------------------------------+
13 rows in set (0.00 sec)

mysql> 
[[email protected] ~]# mysqlbinlog --stop-position=682 /opt/data/mysql_bin.000003 | mysql -uroot -pmarui
mysql: [Warning] Using a password on the command line interface can be insecure.
[[email protected] ~]# 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| runtime            |
| sys                |
+--------------------+
5 rows in set (0.01 sec)

mysql> use runtime;
Database changed
mysql> select * from tb_course;
+----+-------------+
| id | course_name |
+----+-------------+
|  1 | Java        |
|  2 | Mysql       |
|  3 | Python      |
|  4 | Go          |
|  5 | C++         |
|  6 | HTML        |
|  7 | English     |
|  8 | math        |
+----+-------------+
8 rows in set (0.00 sec)

mysql> 

2 mysql多實例部署

  • 1 軟體下載
[[email protected] ~]# cd /usr/src/
[[email protected] src]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
  • 2 配置用戶和組並解壓二進位程式至/usr/local下
[[email protected] src]# id mysql
id: ‘mysql’: no such user
[[email protected] src]# useradd -r -M -s /sbin/nologin mysql
[[email protected] src]# ls
debug  kernels  mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
[[email protected] src]# tar xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[[email protected] src]# cd /usr/local/
[[email protected] local]# ll
total 0
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  6 09:33 lib64
drwxr-xr-x. 2 root root   6 May 19  2020 libexec
drwxr-xr-x. 9 root root 129 Jul 31 17:26 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  6 09:33 share
drwxr-xr-x. 2 root root   6 May 19  2020 src
[[email protected] local]# 
[[email protected] local]# ln -s mysql-5.7.38-linux-glibc2.12-x86_64 mysql
[[email protected] local]# ll
total 0
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  6 09:33 lib64
drwxr-xr-x. 2 root root   6 May 19  2020 libexec
lrwxrwxrwx. 1 root root  35 Jul 31 17:27 mysql -> mysql-5.7.38-linux-glibc2.12-x86_64
drwxr-xr-x. 9 root root 129 Jul 31 17:26 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  6 09:33 share
drwxr-xr-x. 2 root root   6 May 19  2020 src
[[email protected] local]# 
[[email protected] local]# chown -R mysql.mysql mysql*
[[email protected] local]# ll
total 0
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  6 09:33 lib64
drwxr-xr-x. 2 root  root    6 May 19  2020 libexec
lrwxrwxrwx. 1 mysql mysql  35 Jul 31 17:27 mysql -> mysql-5.7.38-linux-glibc2.12-x86_64
drwxr-xr-x. 9 mysql mysql 129 Jul 31 17:26 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  6 09:33 share
drwxr-xr-x. 2 root  root    6 May 19  2020 src
[[email protected] local]# pwd
/usr/local
[[email protected] local]# ls
bin  etc  games  include  lib  lib64  libexec  mysql  mysql-5.7.38-linux-glibc2.12-x86_64  sbin  share  src
[[email protected] local]# cd mysql
[[email protected] mysql]# ls
bin  docs  include  lib  LICENSE  man  README  share  support-files
[[email protected] mysql]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[[email protected] mysql]# source /etc/profile.d/mysql.sh 
[[email protected] mysql]# ln -s /usr/local/mysql/include/ /usr/include/mysql
[[email protected] mysql]# chown -R mysql.mysql /usr/include/mysql
[[email protected] mysql]# ll -d /usr/include/mysql
lrwxrwxrwx. 1 mysql mysql 25 Jul 31 17:31 /usr/include/mysql -> /usr/local/mysql/include/
[[email protected] mysql]# 
[[email protected] mysql]# vim /etc/ld.so.conf.d/mysql.conf

/usr/local/mysql/lib
[[email protected] mysql]# vim /etc/man_db.conf 

MANDATORY_MANPATH                       /usr/man
MANDATORY_MANPATH                       /usr/share/man
MANDATORY_MANPATH                       /usr/local/share/man
MANDATORY_MANPATH                       /usr/local/mysql/man
  • 3 創建各實例數據存放的目錄
[[email protected] ~]# mkdir -p /opt/data/{3306,3307,3308}
[[email protected] ~]# chown -R mysql.mysql /opt/data/
[[email protected] ~]# ll -d /opt/data/
drwxr-xr-x. 5 mysql mysql 42 Jul 31 17:40 /opt/data/
[[email protected] ~]# tree /opt/data/
/opt/data/
├── 3306
├── 3307
└── 3308

3 directories, 0 files
[[email protected] ~]# 

  • 4 初始化各實例
[[email protected] ~]# mysqld --initialize --user mysql --datadir /opt/data/3306
2022-07-31T09:44:28.907046Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-31T09:44:29.040275Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-31T09:44:29.064827Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-31T09:44:29.068832Z 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: 5f337cfb-10b5-11ed-8041-000c2950070e.
2022-07-31T09:44:29.069409Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-31T09:44:29.481826Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T09:44:29.481870Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T09:44:29.482251Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-31T09:44:29.507332Z 1 [Note] A temporary password is generated for [email protected]: ds=WqMxEw5B%
[[email protected] ~]# echo 'ds=WqMxEw5B%' > 3306
[[email protected] ~]# cat 3306
ds=WqMxEw5B%
[[email protected] ~]# 
[[email protected] ~]# mysqld --initialize --user mysql --datadir /opt/data/3307
2022-07-31T09:45:57.115760Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-31T09:45:57.253402Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-31T09:45:57.274926Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-31T09:45:57.279112Z 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: 93c74f09-10b5-11ed-844a-000c2950070e.
2022-07-31T09:45:57.280633Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-31T09:45:57.576351Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T09:45:57.576387Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T09:45:57.576764Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-31T09:45:57.596717Z 1 [Note] A temporary password is generated for [email protected]: LzXC#WG-x1Kd
[[email protected] ~]# echo 'LzXC#WG-x1Kd' > 3307
[[email protected] ~]# cat 3307
LzXC#WG-x1Kd
[[email protected] ~]# mysqld --initialize --user mysql --datadir /opt/data/3308
2022-07-31T09:46:48.315446Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-31T09:46:48.483622Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-31T09:46:48.509017Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-31T09:46:48.517038Z 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: b251987e-10b5-11ed-8604-000c2950070e.
2022-07-31T09:46:48.517584Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-31T09:46:48.708884Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T09:46:48.708917Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T09:46:48.709402Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-31T09:46:48.811564Z 1 [Note] A temporary password is generated for [email protected]: ,L&rJy+Sm9z:
[[email protected] ~]# echo ',L&rJy+Sm9z:' > 3308
[[email protected] ~]# cat 3308
,L&rJy+Sm9z:
[[email protected] ~]# 
[[email protected] ~]# ls
3306  3307  3308  anaconda-ks.cfg

  • 5 安裝perl
[[email protected] ~]# yum -y install perl
......
  python3-rpm-macros-3-42.el8.noarch                                                                            
  qt5-srpm-macros-5.15.3-1.el8.noarch                                                                           
  redhat-rpm-config-125-1.el8.noarch                                                                            
  rust-srpm-macros-5-2.el8.noarch                                                                               
  systemtap-sdt-devel-4.7-1.el8.x86_64                                                                          
  unzip-6.0-46.el8.x86_64                                                                                       
  zip-3.0-23.el8.x86_64                                                                                         

Complete!
[[email protected] ~]# 

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

[[email protected] ~]# 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


    1. 啟動各實例
[[email protected] ~]# mysqld_multi start 3306
[[email protected] ~]# 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            80                             *:3306                        *:*                      
LISTEN       0            128                         [::]:22                       [::]:*                      
[[email protected] ~]# mysqld_multi start 3307
[[email protected] ~]# mysqld_multi start 3308
[[email protected] ~]# 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            80                             *:3306                        *:*                      
LISTEN       0            80                             *:3307                        *:*                      
LISTEN       0            80                             *:3308                        *:*                      
LISTEN       0            128                         [::]:22                       [::]:*                      
[[email protected] ~]# 

    1. 初始化密碼
[[email protected] ~]# ls
3306  3307  3308  anaconda-ks.cfg
[[email protected] ~]# cat 3306
ds=WqMxEw5B%
[[email protected] ~]# mysql -uroot -pds=WqMxEw5B% -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> exit
Bye
[[email protected] ~]# mysql -uroot -p3306 -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.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> 

[[email protected] ~]# cat 3307
LzXC#WG-x1Kd
[[email protected] ~]# mysql -uroot -pLzXC#WG-x1Kd -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.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> exit
Bye
[[email protected] ~]# mysql -uroot -p3307 -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> 


[[email protected] ~]# cat 3308
,L&rJy+Sm9z:
[[email protected] ~]# mysql -uroot -p',L&rJy+Sm9z:' -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> exit
Bye
[[email protected] ~]# 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 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> 



您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 目 錄 1. 概述... 2 2. 設備運維業務... 3 3. “低代碼”表單開發工具... 6 1. 概述 iNeuOS工業互聯網操作系統增加了設備運維業務大屏統計功能和所謂的“低代碼”表單開發工具。 設備運維業務大屏統計功能主要統計當前系統設備數量、預警設備數量、通訊正常、通訊干擾、通訊中斷及 ...
  • head.s 參考 [github這個博主的][ https://github.com/sunym1993/flash-linux0.11-talk ] 改變棧頂位置 _pg_dir: startup_32: movl $0x10,%eax mov %ax,%ds mov %ax,%es mov % ...
  • 曾經的“小霸王”游戲機,讓我們許多80年後、90後度過了一個歡樂愉快的童年,雖然如今這類游戲機和卡帶幾乎已經退出游戲市場,但經典永遠留在了我們這一代人心中。今天給大家分享的小霸王FC經典游戲600合集,帶你回顧童年,重溫經典!希望大家喜歡! 詳情:FC紅白機游戲600合集for mac(小霸王游戲) ...
  • 哪裡有專業級的NTFS格式讀寫工具?Tuxera NTFS 2021 mac中文版是一款非常好用的NTFS讀寫工具,可以讓您完整的讀寫相容NTFS格式驅動器,對磁碟進行訪問、編輯、存儲和傳輸文件等操作。同時還包括開源磁碟管理器等簡單的格式和硬碟維修檢查和修複。 詳情:Tuxera NTFS 2021 ...
  • RAR Extractor是一款非常優秀的壓縮解壓工具,可以幫助用戶提取和預覽多種格式的包(超過 40 種格式),支持解壓RAR、ZIP、7Z、TAR、GZIP、GZ、BZIP2、LZIP、ACE、ISO、PAX、PKG、APK、LBR、MSI、JAR、XZ、LZMA、BZ、LZH、CAB、CPIO ...
  • 拉取nacos docker pull nacos/nacos-server 創建文件夾 日誌文件夾 mkdir -p /root/apply/docker/apply/nacos/logs/ 配置文件夾 mkdir -p /root/apply/docker/apply/nacos/init.d/ ...
  • Xmind 2022 for Mac是一款非常便捷的製作思維導圖的軟體,它有非常豐富的模板可以使用,製作思維導圖可以幫助用戶更高效的進行學習,理清相關學習內容的思路和大體框架,用戶可以根據自己的需求進行自主設計,也可以直接添加模板。 詳情:Xmind 2022 for Mac(思維導圖軟體) 軟體介 ...
  • 基礎知識 ssh:secure shell protocol,安全的遠程登錄 作用:是建立在應用層基礎上的安全協議,實現數據傳輸過程中數據的加密,代替telent協議 使用tcp協議,埠號為22 ssh服務具體的軟體實現: openSSH dropbear OpenSSH:ssh協議的開源實現,l ...
一周排行
    -Advertisement-
    Play Games
  • 一:背景 1.講故事 在分析的眾多dump中,經常會遇到各種奇葩的問題,僅通過dump這種快照形式還是有很多問題搞不定,而通過 perfview 這種粒度又太粗,很難找到問題之所在,真的很頭疼,比如本篇的 短命線程 問題,參考圖如下: 我們在 t2 時刻抓取的dump對查看 短命線程 毫無幫助,我根 ...
  • 在日常後端Api開發中,我們跟前端的溝通中,通常需要協商好入參的數據類型,和參數是通過什麼方式存在於請求中的,是表單(form)、請求體(body)、地址欄參數(query)、還是說通過請求頭(header)。 當協商好後,我們的介面又需要怎麼去接收這些數據呢?很多小伙伴可能上手就是直接寫一個實體, ...
  • 許多情況下我們需要用到攝像頭獲取圖像,進而處理圖像,這篇博文介紹利用pyqt5、OpenCV實現用電腦上連接的攝像頭拍照並保存照片。為了使用和後續開發方便,這裡利用pyqt5設計了個相機界面,後面將介紹如何實現,要點包括界面設計、邏輯實現及完整代碼。 ...
  • 思路分析 註冊頁面需要對用戶提交的數據進行校驗,並且需要對用戶輸入錯誤的地方進行提示! 所有我們需要使用forms組件搭建註冊頁面! 平時我們書寫form是組件的時候是在views.py裡面書寫的, 但是為了接耦合,我們需要將forms組件都單獨寫在一個地方,需要用的時候導入就行! 例如,在項目文件 ...
  • 思路分析 登錄頁面,我們還是採用ajax的方式提交用戶數據 唯一需要學習的是如何製作圖片驗證碼! 具體的登錄頁面效果圖如下: 如何製作圖片驗證碼 推導步驟1:在img標簽的src屬性里放上驗證碼的請求路徑 補充1.img的src屬性: 1.圖片路徑 2.url 3.圖片的二進位數據 補充2:字體樣式 ...
  • 哈嘍,兄弟們! 最近有許多小伙伴都在吐槽打工好難。 每天都是執行許多重覆的任務 例如閱讀新聞、發郵件、查看天氣、打開書簽、清理文件夾等等, 使用自動化腳本,就無需手動一次又一次地完成這些任務, 非常方便啊有木有?! 而在某種程度上,Python 就是自動化的代名詞。 今天就來和大家一起學習一下, 用 ...
  • 作者:IT王小二 博客:https://itwxe.com 前面小二介紹過使用Typora+PicGo+LskyPro打造舒適寫作環境,那時候需要使用水印功能,但是小二在升級LskyPro2.x版本發現有很多不如人意的東西,遂棄用LskyPro使用MinIO結合代碼實現自己需要的圖床功能,也適合以後 ...
  • OpenAI Gym是一款用於研發和比較強化學習演算法的工具包,本文主要介紹Gym模擬環境的功能和工具包的使用方法,並詳細介紹其中的經典控制問題中的倒立擺(CartPole-v0/1)問題。最後針對倒立擺問題如何建立控制模型並採用爬山演算法優化進行了介紹,並給出了相應的完整python代碼示例和解釋。要... ...
  • python爬蟲瀏覽器偽裝 #導入urllib.request模塊 import urllib.request #設置請求頭 headers=("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, l ...
  • 前端代碼搭建 主要利用的是bootstrap3中js插件里的模態框版塊 <li><a href="" data-toggle="modal" data-target=".bs-example-modal-lg">修改密碼</a></li> <div class="modal fade bs-exam ...