mysql差异备份与多实例部署

mysql差异备份与多实例部署


差异备份与恢复
  • 差异备份简单来说就是备份自上一次完整备份之后有变化的数据
//开启mysql服务的二进制日志功能
[root@192 ~]# vim /etc/my.cnf 
[root@192 ~]# cat /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
#skip-grant-tables
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  //开启二进制日志功能

//重启服务生效配置文件
[root@192 ~]# systemctl restart mysqld.service 
[root@192 ~]# ll /opt/data/
total 123004
-rw-r-----. 1 mysql mysql    27420 Jul 31 14:12 192.168.159.162.err
-rw-r-----. 1 mysql mysql       56 Jul 27 15:52 auto.cnf
-rw-------. 1 mysql mysql     1680 Jul 27 15:52 ca-key.pem
-rw-r--r--. 1 mysql mysql     1112 Jul 27 15:52 ca.pem
-rw-r--r--. 1 mysql mysql     1112 Jul 27 15:52 client-cert.pem
-rw-------. 1 mysql mysql     1676 Jul 27 15:52 client-key.pem
drwxr-x---  2 mysql mysql       50 Jul 28 16:12 hhh
-rw-r-----  1 mysql mysql      312 Jul 31 14:12 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Jul 31 14:12 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Jul 31 14:12 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Jul 27 15:52 ib_logfile1
-rw-r-----  1 mysql mysql 12582912 Jul 31 14:12 ibtmp1
-rw-r-----  1 mysql mysql    16228 Jul 29 11:38 localhost.localdomain.err
drwxr-x---. 2 mysql mysql     4096 Jul 27 15:52 mysql
-rw-r-----  1 mysql mysql      154 Jul 31 14:12 mysql_bin.000001 //二进制日志文件
-rw-r-----  1 mysql mysql       19 Jul 31 14:12 mysql_bin.index  //查看事务日志文件是哪个
-rw-r-----  1 mysql mysql        5 Jul 31 14:12 mysql.pid
drwxr-x---. 2 mysql mysql     8192 Jul 27 15:52 performance_schema
-rw-------. 1 mysql mysql     1680 Jul 27 15:52 private_key.pem
-rw-r--r--. 1 mysql mysql      452 Jul 27 15:52 public_key.pem
drwxr-x---. 2 mysql mysql      118 Jul 27 17:00 runtime
-rw-r--r--. 1 mysql mysql     1112 Jul 27 15:52 server-cert.pem
-rw-------. 1 mysql mysql     1676 Jul 27 15:52 server-key.pem
drwxr-x---. 2 mysql mysql     8192 Jul 27 15:52 sys

//对数据库进行全备
[root@192 ~]# mysqldump -uroot -p456 --single-transaction --flush-logs --master-data=2 --all-databases --delete-master-logs > all-chayi.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
[root@192 ~]# ls
all-20220728162632.sql  anaconda-ks.cfg         table-jjj-20220728162957.sql
all-chayi.sql           run-20220728163217.sql

//对数据库数据进行更改
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hhh                |
| mysql              |
| performance_schema |
| runtime            |
| sys                |
+--------------------+
6 rows in set (0.00 sec)

mysql> use runtime
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-------------------+
| Tables_in_runtime |
+-------------------+
| tb_course         |
| tb_students_info  |
+-------------------+
2 rows in set (0.00 sec)
mysql> insert into tb_students_info (name,age,sex,height,course_id)  values('Dog',18,'女',13
35,2);
Query OK, 1 row affected (0.00 sec)

mysql> select * from tb_students_info;
+----+--------+------+------+--------+-----------+
| id | name   | age  | sex  | height | course_id |
+----+--------+------+------+--------+-----------+
|  1 | Dany   |   25 ||    160 |         1 |
|  2 | Green  |   23 ||    158 |         2 |
|  3 | Henry  |   23 ||    185 |         1 |
|  4 | Jane   |   22 ||    162 |         3 |
|  5 | Jim    |   24 ||    175 |         2 |
|  6 | John   |   21 ||    172 |         4 |
|  7 | Lily   |   22 ||    165 |         4 |
|  8 | Susan  |   23 ||    170 |         5 |
|  9 | Thomas |   22 ||    178 |         5 |
| 10 | Tom    |   23 ||    165 |         5 |
| 11 | LiMing |   22 ||    180 |         7 |
| 12 | Dog    |   18 ||    135 |         2 |
+----+--------+------+------+--------+-----------+
12 rows in set (0.00 sec)

mysql> update tb_course set course_name = 'math' where id = 6;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

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

//删除数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hhh                |
| mysql              |
| performance_schema |
| runtime            |
| sys                |
+--------------------+
6 rows in set (0.00 sec)

mysql> drop database runtime;
Query OK, 2 rows affected (0.01 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hhh                |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)


//刷新二进制文件
......
-rw-r-----  1 mysql mysql      905 Jul 31 14:50 mysql_bin.000002
-rw-r-----  1 mysql mysql       19 Jul 31 14:22 mysql_bin.index
......
[root@192 ~]# mysqladmin -uroot -p456 flush-logs
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
[root@192 ~]# ll /opt/data/
......
-rw-r-----  1 mysql mysql      952 Jul 31 14:55 mysql_bin.000002
-rw-r-----  1 mysql mysql      154 Jul 31 14:55 mysql_bin.000003
-rw-r-----  1 mysql mysql       38 Jul 31 14:55 mysql_bin.index
......

//恢复全备数据因为差异备份先要恢复全备数据
   //恢复全备数据
[root@192 ~]# mysql -uroot -p456 < all-chayi.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@192 ~]# mysql -uroot -p456
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 7
Server version: 5.7.38-log 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hhh                |
| mysql              |
| performance_schema |
| runtime            |
| sys                |
+--------------------+
6 rows in set (0.00 sec)

mysql> use runtime;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

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

mysql> select * from tb_students_info;
+----+--------+------+------+--------+-----------+
| id | name   | age  | sex  | height | course_id |
+----+--------+------+------+--------+-----------+
|  1 | Dany   |   25 ||    160 |         1 |
|  2 | Green  |   23 ||    158 |         2 |
|  3 | Henry  |   23 ||    185 |         1 |
|  4 | Jane   |   22 ||    162 |         3 |
|  5 | Jim    |   24 ||    175 |         2 |
|  6 | John   |   21 ||    172 |         4 |
|  7 | Lily   |   22 ||    165 |         4 |
|  8 | Susan  |   23 ||    170 |         5 |
|  9 | Thomas |   22 ||    178 |         5 |
| 10 | Tom    |   23 ||    165 |         5 |
| 11 | LiMing |   22 ||    180 |         7 |
+----+--------+------+------+--------+-----------+
11 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)
   //当前恢复的仅是之前的全备数据,而全备之后对数据库做的操作则没有改变

//查看binlog日志,选择要恢复的数据
   有三种方法
1.mysql> show binlog events in 'mysql_bin.000002';
2.[root@192 ~]# mysqlbinlog mysql_bin.000002
3.[root@192 ~]# cd /opt/data/
[root@192 data]# mysqlbinlog --no-defaults --base64-output=decode-rows -v mysql_bin.000002 > /opt/data/mysql_bin02.txt  //二进制日志转换文本文件,使用该方式查看要看清楚COMMIT的id号

//恢复biglog事务
   根据操作id号恢复
   --stop-postion代表从该日志第一个id号的操作恢复截止至该id号
   --start-postion代表恢复从该id起之后的所有操作
[root@192 ~]# mysqlbinlog --stop-position=888 /opt/data/mysql_bin.000002 | mysql -uroot -p456

//查看binlog日志
mysql> show binlog events in 'mysql_bin.000002';

//找到之前删除库之前的操作id进行恢复
[root@192 ~]# mysqlbinlog --stop-position=739 /opt/data/mysql_bin.000002 | mysql -uroot -p456
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@192 ~]# mysql -uroot -p456
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 10
Server version: 5.7.38-log 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hhh                |
| mysql              |
| performance_schema |
| runtime            |
| sys                |
+--------------------+
6 rows in set (0.01 sec)

mysql> use runtime;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
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 | math        |
+----+-------------+
6 rows in set (0.00 sec)

mysql> select * from tb_students_info;
+----+--------+------+------+--------+-----------+
| id | name   | age  | sex  | height | course_id |
+----+--------+------+------+--------+-----------+
|  1 | Dany   |   25 ||    160 |         1 |
|  2 | Green  |   23 ||    158 |         2 |
|  3 | Henry  |   23 ||    185 |         1 |
|  4 | Jane   |   22 ||    162 |         3 |
|  5 | Jim    |   24 ||    175 |         2 |
|  6 | John   |   21 ||    172 |         4 |
|  7 | Lily   |   22 ||    165 |         4 |
|  8 | Susan  |   23 ||    170 |         5 |
|  9 | Thomas |   22 ||    178 |         5 |
| 10 | Tom    |   23 ||    165 |         5 |
| 11 | LiMing |   22 ||    180 |         7 |
| 12 | Dog    |   18 ||    135 |         2 |
+----+--------+------+------+--------+-----------+
12 rows in set (0.00 sec)

//免密备份
[root@192 ~]# vim .my.cnf
[root@192 ~]# cat .my.cnf 
[mysqldump]
user=root
password=456
mysql多实例部署
  • 二进制格式mysql安装
    • 前往mysql官网下载二进制安装包https://downloads.mysql.com/archives/community/(注意:选择操作系统时选Linux-Generic)我这里下载的是mysql-8.0.29-linux-glibc2.12-x86_64.tar.xz

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

//下载二进制包
[root@192 ~]# cd /usr/src/
[root@192 src]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz

//创建用户
[root@192 src]# useradd -M -r -s /sbin/nologin mysql
[root@192 src]# id mysql 
uid=995(mysql) gid=992(mysql) groups=992(mysql)

//解压二进制包
[root@192 src]# tar xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@192 src]# ls /usr/local/
bin  games    lib    libexec                              sbin   src
etc  include  lib64  mysql-5.7.38-linux-glibc2.12-x86_64  share

//创建软连接
[root@192 ~]# cd /usr/local/
[root@192 local]# ln -sv mysql-5.7.38-linux-glibc2.12-x86_64/ mysql
'mysql' -> 'mysql-5.7.38-linux-glibc2.12-x86_64/'
[root@192 local]# ll
total 0
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 Jul 25 20:12 lib64
drwxr-xr-x. 2 root root   6 Jun 22  2021 libexec
lrwxrwxrwx. 1 root root  36 Jul 31 16:11 mysql -> mysql-5.7.38-linux-glibc2.12-x86_64/
drwxr-xr-x. 9 root root 129 Jul 31 16:09 mysql-5.7.38-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root   6 Jun 22  2021 sbin
drwxr-xr-x. 5 root root  49 Jul 25 20:12 share
drwxr-xr-x. 2 root root   6 Jun 22  2021 src

//修改目录/usr/local/mysql的属主属组
[root@192 local]# chown -R mysql.mysql mysql*
[root@192 local]# ll
total 0
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 Jul 25 20:12 lib64
drwxr-xr-x. 2 root  root    6 Jun 22  2021 libexec
lrwxrwxrwx. 1 mysql mysql  36 Jul 31 16:11 mysql -> mysql-5.7.38-linux-glibc2.12-x86_64/
drwxr-xr-x. 9 mysql mysql 129 Jul 31 16:09 mysql-5.7.38-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root  root    6 Jun 22  2021 sbin
drwxr-xr-x. 5 root  root   49 Jul 25 20:12 share
drwxr-xr-x. 2 root  root    6 Jun 22  2021 src

//添加环境变量
[root@192 local]# cd /usr/local/mysql/bin/
[root@192 bin]# pwd
/usr/local/mysql/bin
[root@192 bin]# echo 'export PATH=$PATH:/usr/local/mysql/bin' > /etc/profile.d/mysql.sh
[root@192 bin]# source /etc/profile.d/mysql.sh
[root@192 bin]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin

//创建头文件软连接到/usr/incloud/mysql
[root@192 ~]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
'/usr/include/mysql' -> '/usr/local/mysql/include/'

//配置lib
[root@192 mysql]# vim /etc/ld.so.conf.d/mysql.comf
[root@192 mysql]# cat /etc/ld.so.conf.d/mysql.comf
/usr/local/mysql/lib/
[root@192 mysql]# ldconfig 

//配置man
[root@192 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

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

[root@192 ~]# mkdir -p /opt/data/{3306,3307,3308}
[root@192 ~]# chown -R mysql.mysql /opt/data/
[root@192 ~]# ll /opt/data/
total 0
drwxr-xr-x. 2 mysql mysql 6 Jul 31 16:21 3306
drwxr-xr-x. 2 mysql mysql 6 Jul 31 16:21 3307
drwxr-xr-x. 2 mysql mysql 6 Jul 31 16:21 3308
[root@192 ~]# tree /opt/data/
/opt/data/
├── 3306
├── 3307
└── 3308

3 directories, 0 files

初始化各实例

//初始化3306实例
[root@192 ~]# mysqld --initialize --datadir=/opt/data/3306 --user=mysql
2022-07-31T08:23:14.334426Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-31T08:23:14.519492Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-31T08:23:14.551326Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-31T08:23:14.556756Z 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: 05c3f8ff-10aa-11ed-9d4c-000c29a9872e.
2022-07-31T08:23:14.557418Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-31T08:23:14.667858Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T08:23:14.667894Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T08:23:14.668216Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-31T08:23:14.786869Z 1 [Note] A temporary password is generated for root@localhost: ao81s=ittr1C
[root@192 ~]# echo 'ao81s=ittr1C' > 3306_pass

//初始化3307实例
[root@192 ~]# mysqld --initialize --datadir=/opt/data/3307 --user=mysql
2022-07-31T08:25:14.593470Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-31T08:25:14.769617Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-31T08:25:14.797695Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-31T08:25:14.854855Z 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: 4d780147-10aa-11ed-9ff2-000c29a9872e.
2022-07-31T08:25:14.855885Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-31T08:25:15.157436Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T08:25:15.157475Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T08:25:15.157805Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-31T08:25:15.383867Z 1 [Note] A temporary password is generated for root@localhost: mz2;8IIG.X6l
[root@192 ~]# echo 'mz2;8IIG.X6l' > 3307_pass

//初始化3308实例
[root@192 ~]# mysqld --initialize --datadir=/opt/data/3308 --user=mysql
2022-07-31T08:26:04.569606Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-31T08:26:04.765609Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-31T08:26:04.797268Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-31T08:26:04.855162Z 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: 6b457294-10aa-11ed-a2d7-000c29a9872e.
2022-07-31T08:26:04.856614Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-31T08:26:04.961061Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T08:26:04.961091Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-31T08:26:04.961389Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-31T08:26:05.039419Z 1 [Note] A temporary password is generated for root@localhost: IZouUS%Nj8+p
[root@192 ~]# echo 'IZouUS%Nj8+p' > 3308_pass

安装perl

[root@192 ~]# yum -y install perl

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

[root@192 ~]# vim /etc/my.cnf
[root@192 ~]# 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
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@192 ~]# mysqld_multi start 3306
[root@192 ~]# mysqld_multi start 3307
[root@192 ~]# mysqld_multi start 3308
[root@192 ~]# 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                  [::]:* 

初始化密码

//3306
[root@192 ~]# mysql -uroot -p'ao81s=ittr1C' -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> 
mysql> set password = password('123');
Query OK, 0 rows affected, 1 warning (0.00 sec)

//3307
[root@192 ~]# cat 3307_pass 
mz2;8IIG.X6l
[root@192 ~]# mysql -uroot -p'mz2;8IIG.X6l' -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('123');
Query OK, 0 rows affected, 1 warning (0.00 sec)

//3308
[root@192 ~]# cat 3308_pass 
IZouUS%Nj8+p
[root@192 ~]# mysql -uroot -p'IZouUS%Nj8+p' -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('123');
Query OK, 0 rows affected, 1 warning (0.00 sec)
 -p'IZouUS%Nj8+p' -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('123');
Query OK, 0 rows affected, 1 warning (0.00 sec)
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

随便投投

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值