MySQL数据库-跨版本迁移
前言
MySQL数据库不同版本之间进行数据迁移。
迁移的方式,目前有三种方式:
- mysqldump 进行导出/导入
- 物理文件迁移:拷贝 .ibd 文件至目标库,进行导入.
- 备份/恢复 原地升级
环境介绍
当前环境如下:
源库
数据库版本:5.7.26
数据库架构:主从
操作系统版本:Red Hat Enterprise Linux Server release 7.5 (Maipo)
节点信息:
IP地址 | 状态 |
---|---|
192.168.88.31 | 主库 |
192.168.88.32 | 从库 |
目标库
数据库版本:8.0.32
数据库架构:主从
操作系统版本:Red Hat Enterprise Linux Server release 7.5 (Maipo)
节点信息:
IP地址 | 状态 |
---|---|
192.168.88.33 | 主库 |
192.168.88.34 | 从库 |
数据准备
- 测试数据:在
源库
中创建testdb
库,其内有两张表:client、client_info ,每张表各 1000条 数据。
【测试数据下载地址:《【1】MySQL数据库-创建测试数据》】
[root@localhost][testdb]> select count(*) from client;
+----------+
| count(*) |
+----------+
| 1000 |
+----------+
1 row in set (0.00 sec)
[root@localhost][testdb]> select count(*) from client_info;
+----------+
| count(*) |
+----------+
| 1000 |
+----------+
1 row in set (0.00 sec)
[root@localhost][testdb]>
数据迁移
在实际迁移过程中,应用程序一般是会连接数据库的、且实时会有数据进来(即:数据库实时会有新事务产生);
在迁移之前,会有统一步骤,例如:锁业务账号、设置只读、锁库(非必须),若非生成环境,对数据一致性要求不高此步骤可忽略。在各迁移方式中不在分别写入该步骤,现提前统一:
- 锁账号(业务账号:
fid_test
)
-- 锁住账号
[root@localhost][mysql]> alter user fid_test@'%' account lock;
Query OK, 0 rows affected (0.00 sec)
-- 查看账号是否已被锁
[root@localhost][mysql]> select user,host, account_locked from user where user = 'fid_test';
+----------+------+----------------+
| user | host | account_locked |
+----------+------+----------------+
| fid_test | % | Y |
+----------+------+----------------+
1 row in set (0.00 sec)
--
-- 若需解锁,执行如下SQL:
-- 解锁账号
[root@localhost][mysql]> alter user fid_test@'%' account unlock;
Query OK, 0 rows affected (0.00 sec)
[root@localhost][mysql]> select user,host, account_locked from user where user = 'fid_test';
+----------+------+----------------+
| user | host | account_locked |
+----------+------+----------------+
| fid_test | % | N |
+----------+------+----------------+
1 row in set (0.00 sec)
- 设置只读(主/从 各节点均需要单独执行)
如下是通过 SQL 语句进行设置,数据库一旦重启、只读将会失效。
若想更稳妥一些,需修改配置文件my.cnf
,该配置文件位置一般放在/etc/my.cnf
(此处位置优先加载),配置文件不同存放位置,可通过如下命令查看:
配置文件系列:只读
[root@localhost mysql]# mysql --help | grep "Default options" -A 1
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
[root@localhost mysql]#
当前配置文件存放在了/etc/my.cnf
,使用 vi 命令编辑配置文件,修改 read_only 参数,将其参数值设置为 1 即可。
## 修改后的参数值如下:
[root@localhost mysql]# cat /etc/my.cnf | grep -i read_only
read_only = 1
[root@localhost mysql]#
SQL语句系列:只读
-- 设置为只读;若需解除只读:将 on 换成 off
[root@localhost][(none)]> set global read_only = on;
Query OK, 0 rows affected (0.00 sec)
[root@localhost][(none)]>
[root@localhost][(none)]> show variables like 'read_only';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| read_only | ON |
+---------------+-------+
1 row in set (0.00 sec)
- 锁库(主/从 各节点均需要单独执行)
-- 锁库,**当前会话一旦关闭:此锁,将会自动释放**。
[root@localhost][testdb]> flush tables with read lock;
Query OK, 0 rows affected (0.01 sec)
-- 查看 GTID事务号是否变动
[root@localhost][mysql]> show master status;
+------------------+----------+--------------+------------------+--------------------------------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+--------------------------------------------+
| mysql-bin.000005 | 1224273 | | | 903316cd-27ca-11ee-a484-000c29ea6ce5:1-31
+------------------+----------+--------------+------------------+--------------------------------------------+
1 row in set (0.00 sec)
-- 或者:尝试产生一个事务,将会有报错提示:
[root@localhost][mysql]> create database test1001;
ERROR 1223 (HY000): Can't execute the query because you have a conflicting read lock
[root@localhost][mysql]>
-- 在或者执行:show processlist;
-- 如果存在一个名为 FLUSH TABLES 的进程,并且状态显示为 Waiting for table flush,那么表锁定已经生效了。
[root@localhost][(none)]> show processlist;
+----+-----------------+---------------------+------+------------------+------+---------------------------------------------------------------+--------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-----------------+---------------------+------+------------------+------+---------------------------------------------------------------+--------------------------+
| 1 | event_scheduler | localhost | NULL | Daemon | 616 | Waiting on empty queue | NULL |
| 4 | fid_repluser | 192.168.88.32:62190 | NULL | Binlog Dump GTID | 561 | Master has sent all binlog to slave; waiting for more updates | NULL |
| 5 | root | localhost | NULL | Query | 0 | starting | show processlist |
| 6 | root | localhost | NULL | Query | 4 | Waiting for global read lock | create database test1001 |
+----+-----------------+---------------------+------+------------------+------+---------------------------------------------------------------+--------------------------+
4 rows in set (0.00 sec)
--
-- 如果需要解锁,执行如下SQL:
[root@localhost][(none)]> unlock tables;
Query OK, 0 rows affected (0.00 sec)
方式一:mysqldump 迁移
- 在源库中执行如下 命令,进行导出:
##(1) 查看当前所在目录.
[root@localhost tmp]# pwd
/tmp
##(2) 进行数据导出.
[root@localhost tmp]# mysqldump -uroot -p123456 -B testdb --single-transaction --routines --triggers --events --set-gtid-purged=off > testdb.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
[root@localhost tmp]#
##(3) 查看导出的文件.
[root@localhost tmp]# ls -lh testdb.sql
-rw-r--r--. 1 root root 278K Mar 16 22:49 testdb.sql
[root@localhost tmp]#
- 通过
scp
命令将文件传输给 目标库
[root@localhost tmp]# scp testdb.sql root@192.168.88.33:/tmp/
The authenticity of host '192.168.88.33 (192.168.88.33)' can't be established.
ECDSA key fingerprint is SHA256:oOGVJ0qhwef57brL+Gev6JYPQYIB7bGXqfCOPPwkkV8.
ECDSA key fingerprint is MD5:a0:c4:91:5a:5a:d1:3e:cb:6d:c8:07:6c:b8:f7:bb:66.
Are you sure you want to continue connecting (yes/no)? yes ## 这里输入 yes
Warning: Permanently added '192.168.88.33' (ECDSA) to the list of known hosts.
root@192.168.88.33's password: ## 然后在输入一次密码,不会显示、正常输入即可。
testdb.sql 100% 277KB 8.7MB/s 00:00 ## 看到进度100%,说明传输完成.
[root@localhost tmp]#
- 登录目标库,先创建
testdb
数据库
[root@localhost][(none)]> create database testdb;
Query OK, 1 row affected (0.00 sec)
- 目标库:进行数据导入,命令如下:
[root@testdbmy01 ~]# mysql -uroot -p123456 testdb < /tmp/testdb.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@testdbmy01 ~]#
- 目标库:验证,确保数据迁移成功。
[root@localhost][(none)]> show tables from testdb;
+------------------+
| Tables_in_testdb |
+------------------+
| client |
| client_info |
+------------------+
2 rows in set (0.01 sec)
[root@localhost][(none)]> select count(*) from testdb.client;
+----------+
| count(*) |
+----------+
| 1000 |
+----------+
1 row in set (0.05 sec)
[root@localhost][(none)]> select count(*) from testdb.client_info;
+----------+
| count(*) |
+----------+
| 1000 |
+----------+
1 row in set (0.05 sec)
[root@localhost][(none)]>
方式二:物理文件迁移
物理文件迁移这种玩法,是通过拷贝 .ibd
文件,那么也就意味着:这个参数innodb_file_per_table
是打开的状态。
[root@localhost][(none)]> show variables like 'innodb_file_per_table';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_file_per_table | ON |
+-----------------------+-------+
1 row in set (0.00 sec)
每创建一张表,都会单独存放在一个表空间中,存放在 datadir
这个变量的路径中。
如下,可得知:当前是存放在了/mysql/data/
这个路径中。
[root@localhost][(none)]> show variables like 'datadir';
+---------------+--------------+
| Variable_name | Value |
+---------------+--------------+
| datadir | /mysql/data/ |
+---------------+--------------+
1 row in set (0.01 sec)
查看
[root@testdbmy01 ~]# ls -lh /mysql/data/testdb/*
-rw-r-----. 1 mysql mysql 240K Mar 16 23:05 /mysql/data/testdb/client.ibd
-rw-r-----. 1 mysql mysql 240K Mar 16 23:05 /mysql/data/testdb/client_info.ibd
[root@testdbmy01 ~]#
现开始进行数据迁移步骤:
- 源库:查看需要迁移表的结构。将表结构在
目标库
中进行创建。
[root@localhost][testdb]> show create table client \G
*************************** 1. row ***************************
Table: client
Create Table: CREATE TABLE `client` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`client_id` bigint(20) NOT NULL COMMENT 'ID编号',
`user_no` varchar(30) DEFAULT NULL COMMENT '账号',
`user_password` varchar(60) DEFAULT NULL COMMENT '密码',
`nick_name` varchar(30) DEFAULT NULL COMMENT '昵称',
`real_name` varchar(30) DEFAULT NULL COMMENT '真实姓名',
`created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`upated_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=utf8mb4
1 row in set (0.00 sec)
[root@localhost][testdb]> show create table client_info \G
*************************** 1. row ***************************
Table: client_info
Create Table: CREATE TABLE `client_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`client_info_id` bigint(20) NOT NULL COMMENT 'ID编号',
`id_card_no` varchar(30) DEFAULT NULL COMMENT '身份证ID编号',
`mobile_phone` varchar(30) DEFAULT NULL COMMENT '手机号码',
`gender` char(5) DEFAULT NULL COMMENT '性别',
`height` int(11) DEFAULT NULL COMMENT '身高',
`weight` int(11) DEFAULT NULL COMMENT '体重',
`political` varchar(30) DEFAULT NULL COMMENT '政治面貌',
`marital` varchar(30) DEFAULT NULL COMMENT '婚姻状况',
`hobby` varchar(50) DEFAULT NULL COMMENT '爱好',
`created_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`upated_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
`client_id` bigint(20) NOT NULL COMMENT '外键-客户ID编号.',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1001 DEFAULT CHARSET=utf8mb4
1 row in set (0.00 sec)
[root@localhost][testdb]>
- 目标库:卸载表空间,执行如下SQL
-- 卸载 client 表的 表空间
[root@localhost][(none)]> alter table testdb.client discard tablespace;
Query OK, 0 rows affected (0.01 sec)
-- 卸载 client_info 表的 表空间
[root@localhost][(none)]> alter table testdb.client_info discard tablespace;
Query OK, 0 rows affected (0.01 sec)
-- 表空间卸载完成之后,表还是会存在的。
[root@localhost][(none)]> show tables from testdb;
+------------------+
| Tables_in_testdb |
+------------------+
| client |
| client_info |
+------------------+
2 rows in set (0.00 sec)
-- 查看表空间之前的文件,已经被删除了。
[root@localhost][(none)]> system ls -lh /mysql/data/testdb/
total 0
[root@localhost][(none)]>
- 源库执行
FLUSH TABLES ... FOR EXPORT
, 该表这时候处于 quiesce 状态,只读,且创建.cfg metadata文件
[root@localhost][testdb]> flush tables client for export;
Query OK, 0 rows affected (0.00 sec)
-- 执行此之前,需执行 unlock tables; 进行解锁。
-- 在解锁之前,先将 client.cfg 文件 copy 走至目标端。
[root@localhost][testdb]> flush tables client_info for export;
Query OK, 0 rows affected (0.00 sec)
上述sql执行完成后,可看到生成的cfg文件
[root@localhost ~]# cd /mysql/data/testdb/
[root@localhost testdb]# ls -lh
total 480K
-rw-r-----. 1 mysql mysql 8.8K Mar 16 22:04 client.frm
-rw-r-----. 1 mysql mysql 224K Mar 16 22:06 client.ibd
-rw-r-----. 1 mysql mysql 1.1K Mar 16 23:20 client_info.cfg ##-- client.cfg 已经拷贝至目标端.
-rw-r-----. 1 mysql mysql 9.0K Mar 16 22:05 client_info.frm
-rw-r-----. 1 mysql mysql 224K Mar 16 22:06 client_info.ibd
-rw-r-----. 1 mysql mysql 67 Jul 8 2023 db.opt
[root@localhost testdb]#
- 源库:将源库中的
.ibd
和.cfg
文件拷贝到目标库中,路径:/mysql/data/testdb/
[root@localhost testdb]# scp client_info.cfg root@192.168.88.33:/mysql/data/testdb/
root@192.168.88.33's password:
client_info.cfg 100% 1119 3.6MB/s 00:00
[root@localhost testdb]#
[root@localhost testdb]# scp client_info.ibd root@192.168.88.33:/mysql/data/testdb/
root@192.168.88.33's password:
client_info.ibd 100% 224KB 67.4MB/s 00:00
[root@localhost testdb]#
- 目标库 导入表空间即可。
查看/mysql/data/testdb
文件夹中已经有相关文件了。
[root@testdbmy01 testdb]# pwd
/mysql/data/testdb
## 文件已经存在
## 但是-注意:文件权限不对,当前不修改;进行导入、查看报错日志(学习下)
[root@testdbmy01 testdb]# ls -lh
total 456K
-rw-r-----. 1 root root 810 Mar 16 23:28 client.cfg
-rw-r-----. 1 root root 224K Mar 16 23:28 client.ibd
-rw-r-----. 1 root root 1.1K Mar 16 23:27 client_info.cfg
-rw-r-----. 1 root root 224K Mar 16 23:28 client_info.ibd
[root@testdbmy01 testdb]#
导入表空间
-- 发现导入表空间报错,这个是因为 文件权限不对引起的。
-- 应该将 .cfg 、.ibd 文件的权限(所属用户)修改为 mysql
[root@localhost][(none)]> alter table testdb.client import tablespace;
ERROR 1812 (HY000): Tablespace is missing for table `testdb`.`client`.
[root@localhost][(none)]>
--
-- 修改权限
[root@localhost][(none)]> system chown mysql.mysql /mysql/data/testdb/*
[root@localhost][(none)]> system ls -lh /mysql/data/testdb/
total 456K
-rw-r-----. 1 mysql mysql 810 Mar 16 23:28 client.cfg
-rw-r-----. 1 mysql mysql 224K Mar 16 23:28 client.ibd
-rw-r-----. 1 mysql mysql 1.1K Mar 16 23:27 client_info.cfg
-rw-r-----. 1 mysql mysql 224K Mar 16 23:28 client_info.ibd
[root@localhost][(none)]>
--
-- 再次尝试导入表空间
[root@localhost][testdb]> alter table client import tablespace;
Query OK, 0 rows affected (0.03 sec)
[root@localhost][testdb]>
[root@localhost][testdb]> alter table client_info import tablespace;
Query OK, 0 rows affected (0.01 sec)
在目标库,验证:
[root@localhost][testdb]> select count(*) from client;
+----------+
| count(*) |
+----------+
| 1000 |
+----------+
1 row in set (0.05 sec)
[root@localhost][testdb]>
[root@localhost][testdb]> select count(*) from client_info;
+----------+
| count(*) |
+----------+
| 1000 |
+----------+
1 row in set (0.05 sec)
[root@localhost][testdb]>
[root@localhost][testdb]> select * from client limit 1 \G
*************************** 1. row ***************************
id: 1
client_id: 1
user_no: iaMHg4Uh
user_password: 4tBiW078JrEQHqxHxb2kRMwdgCdcWqaC
nick_name: 孤胆英雄
real_name: 司端
created_time: 2024-03-16 22:05:44
upated_time: 2024-03-16 22:05:44
1 row in set (0.00 sec)
[root@localhost][testdb]>
方式三:备份/恢复 原地升级
大致思路步骤:
- 在源库:备份全库
- 将源库上 mysql5.7 版本相关文件,传递至目标库
- 在目标库:先安装mysql8.0的库、然后铲掉(库、数据文件等;仅保留软件)
- 在目标库:用步骤2 传递来的文件:mysql5.7 版本,进行恢复,然后停库。
- 在目标库:用步骤3 保留的 MySQL8 版本软启动 步骤4 中恢复的数据文件。
数据迁移步骤:
- 源库:全量备份。
DATE=`date +%Y%m%d%H`
mkdir -p /backup/$DATE
/usr/bin/mysqlbackup --user=root --password=123456 --compress --compress-level=9 --backup-dir=/backup/$DATE/ backup-and-apply-log
# 输出的日志中,务必不要有 error 报错,看到 success 即可,部分日志如下:
... ...
240316 23:56:32 MAIN INFO: 1035 MB of data files compressed to 4785 kbytes (compression 99.55%).
240316 23:56:32 MAIN INFO: Compress Apply Backup operation completed successfully.
mysqlbackup completed OK!
打包文件:
## 打包全量备份的文件.
[root@localhost backup]# tar -cf 2024031623.tar 2024031623
## 打包 mysql5.7 版本的软件
[root@localhost local]# tar cf mysql57.tar mysql/
- 源库:传递文件至目标库
##(1) 将 mysql5.7 版本的软件,传递至目标库
[root@localhost local]# scp mysql57.tar root@192.168.88.33:/soft/
##(2)将 全量备份文件 传递至目标库.
[root@localhost backup]# scp 2024031623.tar root@192.168.88.33:/backup/
##(3)将 mysql5.7 版本的 mysqlbackup 传递至目标库
[root@localhost backup]# scp /usr/bin/mysqlbackup root@192.168.88.33:/soft/mysqlbackup_57
##(4)将 mysql5.7 版本的配置文件 /etc/my.cnf 传递至目标库
[root@localhost backup]# scp /etc/my.cnf root@192.168.88.33:/etc/my_57.cnf
- 目标库:恢复5.7版本的库。
解压备份文件
[root@testdbmy01 soft]# cd /backup/
[root@testdbmy01 backup]# tar -xf 2024031623.tar
解压5.7版本的软件
[root@testdbmy01 local]# cd /soft/
[root@testdbmy01 soft]# tar -xf mysql57.tar
[root@testdbmy01 soft]# mv mysql mysql57
停止 mysql 8.0 软件,并铲除默认的系统库等文件.(建议:在铲除之前可做下全量备份,此处省略.)
## 停掉 mysql8.0 版本软件.
[root@testdbmy01 local]# service mysqld stop
Shutting down MySQL.. SUCCESS!
## 铲除 mysql8.0 版本相关文件
[root@testdbmy01 local]# rm -rf /mysql
[root@testdbmy01 local]#
- 目标库 恢复 5.7 版本相关库
## 创建数据库所需要的安装路径
mkdir -p /mysql/{data,logs,binlog,tmp}
touch /mysql/logs/{mysql-error.log,mysql-slow.log}
## 修改 /etc/my_57.cnf 文件中的软件路径,改成 /soft/mysql57
## mysql5.7 版本的软件,放置在了 /soft/ 目录中
[root@testdbmy01 mysql57]# cat /etc/my_57.cnf | grep -i basedir
basedir = /soft/mysql57
## 恢复
/soft/mysqlbackup_57 --defaults-file=/etc/my_57.cnf --datadir=/mysql/data --uncompress --backup-dir=/backup/2024031623/ copy-back
## 修改权限
chown -R mysql.mysql /mysql
##
## 用 mysql5.7 版本软件启动数据库,检查是否正常.
## 启动数据库.
/soft/mysql57/bin/mysqld --defaults-file=/etc/my_57.cnf --user=mysql
## 登录数据库进行验证.==>> 无问题.
[root@testdbmy01 soft]# mysql -uroot -p123456
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.26-log MySQL Community Server (GPL)
Copyright (c) 2000, 2023, 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.
[root@localhost][(none)]>
[root@localhost][(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| db1001 |
| mysql |
| performance_schema |
| sys |
| t1 |
| t2 |
| tdb1 |
| tdb2 |
| test1001 |
| testdb |
+--------------------+
11 rows in set (0.00 sec)
[root@localhost][(none)]> select count(*) from testdb.client;
+----------+
| count(*) |
+----------+
| 1000 |
+----------+
1 row in set (0.00 sec)
[root@localhost][(none)]> select count(*) from testdb.client_info;
+----------+
| count(*) |
+----------+
| 1000 |
+----------+
1 row in set (0.00 sec)
[root@localhost][(none)]>
[root@localhost][(none)]> select * from testdb.client limit 1\G
*************************** 1. row ***************************
id: 1
client_id: 1
user_no: iaMHg4Uh
user_password: 4tBiW078JrEQHqxHxb2kRMwdgCdcWqaC
nick_name: 孤胆英雄
real_name: 司端
created_time: 2024-03-16 22:05:44
upated_time: 2024-03-16 22:05:44
1 row in set (0.00 sec)
[root@localhost][(none)]>
- 目标库 停用 mysql5.7 版本启动的库,然后使用 mysql8.0 版本进行启动。
停止数据库(5.7版本)
[root@localhost][(none)]> flush tables;
Query OK, 0 rows affected (0.00 sec)
[root@localhost][(none)]> shutdown;
Query OK, 0 rows affected (0.00 sec)
[root@localhost][(none)]> exit
Bye
[root@testdbmy01 soft]#
[root@testdbmy01 soft]# ps -ef | grep mysql
root 5776 4323 0 00:31 pts/1 00:00:00 grep --color=auto mysql
[root@testdbmy01 soft]#
使用 mysql8 版本软件进行启动
[root@testdbmy01 soft]# service mysqld start
Starting MySQL......... SUCCESS!
[root@testdbmy01 soft]#
[root@testdbmy01 soft]#
[root@testdbmy01 soft]# ps -ef | grep mysql
root 5834 1 0 00:31 pts/1 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/mysql/data --pid-file=/mysql/data/testdbmy01.pid
mysql 7204 5834 41 00:31 pts/1 00:00:07 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/mysql/logs/mysql-error.log --open-files-limit=65535 --pid-file=/mysql/data/testdbmy01.pid --socket=/mysql/tmp/mysql.sock --port=3306
root 7580 4323 0 00:31 pts/1 00:00:00 grep --color=auto mysql
[root@testdbmy01 soft]#
[root@testdbmy01 soft]#
登录 mysql8 版本数据库,经验证,无问题。
[root@testdbmy01 soft]# mysql -uroot -p123456
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 11
Server version: 8.0.32 MySQL Community Server - GPL
Copyright (c) 2000, 2023, 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.
[root@localhost][(none)]>
[root@localhost][(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| db1001 |
| information_schema |
| mysql |
| performance_schema |
| sys |
| t1 |
| t2 |
| tdb1 |
| tdb2 |
| test1001 |
| testdb |
+--------------------+
11 rows in set (0.01 sec)
[root@localhost][(none)]>
[root@localhost][(none)]> select count(*) from testdb.client;
+----------+
| count(*) |
+----------+
| 1000 |
+----------+
1 row in set (0.04 sec)
[root@localhost][(none)]> select count(*) from testdb.client_info;
+----------+
| count(*) |
+----------+
| 1000 |
+----------+
1 row in set (0.05 sec)
[root@localhost][(none)]>
[root@localhost][(none)]> select * from testdb.client limit 1 \G
*************************** 1. row ***************************
id: 1
client_id: 1
user_no: iaMHg4Uh
user_password: 4tBiW078JrEQHqxHxb2kRMwdgCdcWqaC
nick_name: 孤胆英雄
real_name: 司端
created_time: 2024-03-16 22:05:44
upated_time: 2024-03-16 22:05:44
1 row in set (0.00 sec)
[root@localhost][(none)]>