首页 > 数据库 >mysql-utilities对比两个库数据一致性

mysql-utilities对比两个库数据一致性

时间:2023-11-09 11:05:44浏览次数:47  
标签:test1 -- pass utilities server2 test 192.168 mysql 一致性

1.安装mysql-utilities

首先yum源安装python, 之后根据python版本下载安装mysql-connector-python
yum install python
python --version
python 2.6.6

下载地址:https://downloads.mysql.com/archives/c-python/
rpm -ivh mysql-connector-python-2.1.6-1.el6.x86_64.rpm
which python

之后安装 mysql-utilities
下载地址:https://downloads.mysql.com/archives/utilities/
[root@redhat1 ~]# rpm -ivh mysql-utilities-1.6.5-1.el6.noarch.rpm
warning: mysql-utilities-1.6.5-1.el6.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing… ########################################### [100%]
1:mysql-utilities ########################################### [100%]
mysql-utilities安装后会有2个命令工具:mysqldbcompare、mysqldiff

[root@redhat1 bin]# which mysqldbcompare
/usr/bin/mysqldbcompare

2.Mysqldbcompare工具

2.1mysqldbcompare的语法如下:

$ mysqldbcompare --server1=user:pass@host:port:socket --server2=user:pass@host:port:socket db1:db2
以上参数中:
 
--server1:MySQL服务器1配置。
--server2:MySQL服务器2配置。如果是同一服务器,--server2可以省略。
db1:db2:要比较的两个数据库。如果比较不同服务器上的同名数据库,可以省略:db2。
--all:比较所有两服务器上所有的同名数据库。--exclude排除无需比较的数据库。
--run-all-tests:运行完整比较,遇到第一次差异时不停止。
--changes-for=:修改对象。例如--changes-for=server2,那么对比以sever1为主,生成的差异的修改也是针对server2的对象的修改。
-d DIFFTYPE,--difftype=DIFFTYPE:差异的信息显示的方式,有[unified|context|differ|sql],默认是unified。如果使用sql,那么就直接生成差异的SQL,这样非常方便。
--show-reverse:在生成的差异修改里面,同时会包含server2和server1的修改。
--skip-table-options:保持表的选项不变,即对比的差异里面不包括表名、AUTO_INCREMENT、ENGINE、CHARSET等差异。
--skip-diff:跳过对象定义比较检查。所谓对象定义,就是CREATE语句()里面的部分,--skip-table-options是()外面的部分。
--skip-object-compare:默认情况下,先检查两个数据库中相互缺失的对象,再对都存在对象间的差异。这个参数的作用就是,跳过第一步,不检查相互缺失的对象。
--skip-checksum-table:数据一致性验证时跳过CHECKSUM TABLE。
--skip-data-check:跳过数据一致性验证。
--skip-row-count:跳过字段数量检查。
使用mysqldbcompare找出差异化数据

2.2可对比的内容:

可对比出2个库中的对象个数是否一致;
可对比出表数据量区别,有主键的表可列出差异的数据,无主键表只提示数据量不一致。
可对比出有主键的表的实际数据的区别,有主键的表一行记录中某非主键字段值不一致会列出。
无法对比出非主键表数据量一致,某行记录数据值不一致 。

2.3个人测试:

以server2为准,看server1的区别在哪:
/usr/bin/mysqldbcompare --server1=root:[email protected]:3306 --server2=root:[email protected]:3306 --run-all-test --changes-for=server1 --difftype=sql test:test1

以server1 为准,看server2的区别在哪,列出server2的修改sql:
/usr/bin/mysqldbcompare --server1=root:[email protected]:3306 --server2=root:[email protected]:3306 --run-all-test --changes-for=server2 --difftype=sql test:test1

2.3.1一开始 test2,test3,test4表不存在于test1库。 mn2,mn1 没有主键和自增。

[root@redhat1 bin]# /usr/bin/mysqldbcompare --server1=root:[email protected]:3306 --server2=root:[email protected]:3306 --run-all-test --changes-for=server2 --difftype=sql test:test1
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.56.101: ... connected.
# server2 on 192.168.56.101: ... connected.
# Checking databases test on server1 and test1 on server2
#
# WARNING: Objects in server1.test but not in server1.test1:
#        TABLE: test4
#        TABLE: test3
#        TABLE: test2
#
#                                                   Defn    Row     Data   
# Type      Object Name                             Diff    Count   Check  
# ------------------------------------------------------------------------- 
# TABLE     mn1                                     FAIL    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# Transformation for --changes-for=server2:
#
 
ALTER TABLE `test1`.`mn1` 
  ADD PRIMARY KEY(`id`), 
  CHANGE COLUMN id id int(11) NOT NULL, 
AUTO_INCREMENT=13;
 
# The table mn1 does not have an usable Index or primary key.
 
# TABLE     mn2                                     FAIL    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# Transformation for --changes-for=server2:
#
 
ALTER TABLE `test1`.`mn2` 
  ADD PRIMARY KEY(`id`), 
  CHANGE COLUMN id id int(11) NOT NULL, 
AUTO_INCREMENT=34;
 
# The table mn2 does not have an usable Index or primary key.
 
 
# Database consistency check failed.
#
# ...done

2.3.2所有表结构都一致,test2表在test1库中无数据。

[root@redhat1 ~]# /usr/bin/mysqldbcompare --server1=root:[email protected]:3306 --server2=root:[email protected]:3306 --run-all-test --changes-for=server2 --difftype=sql test:test1
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.56.101: ... connected.
# server2 on 192.168.56.101: ... connected.
# Checking databases test on server1 and test1 on server2
#
#                                                   Defn    Row     Data   
# Type      Object Name                             Diff    Count   Check  
# ------------------------------------------------------------------------- 
# TABLE     mn1                                     pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     mn2                                     pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     test2                                   pass    FAIL    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# Row counts are not the same among `test`.`test2` and `test1`.`test2`.
#
# The table test2 does not have an usable Index or primary key.
 
# TABLE     test3                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# The table test3 does not have an usable Index or primary key.
 
# TABLE     test4                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# The table test4 does not have an usable Index or primary key.
 
 
# Database consistency check failed.
#
# ...done
[root@redhat1 ~]#

2.3.3test,test1 库完全一致: 表无主键 数据量对比会显示skip 。

[root@redhat1 ~]# /usr/bin/mysqldbcompare --server1=root:[email protected]:3306 --server2=root:[email protected]:3306 --run-all-test --changes-for=server2 --difftype=sql test:test1
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.56.101: ... connected.
# server2 on 192.168.56.101: ... connected.
# Checking databases test on server1 and test1 on server2
#
#                                                   Defn    Row     Data   
# Type      Object Name                             Diff    Count   Check  
# ------------------------------------------------------------------------- 
# TABLE     mn1                                     pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     mn2                                     pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     test2                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# The table test2 does not have an usable Index or primary key.
 
# TABLE     test3                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# The table test3 does not have an usable Index or primary key.
 
# TABLE     test4                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# The table test4 does not have an usable Index or primary key.
 
 
# Database consistency check failed.
#
# ...done

2.3.4 test2,test4, mn1 表的数据量在test库都比test1库中多:

有主键的会详细列出具体的数据差异,没有主键的只提示数据量不一致

[root@redhat1 ~]# /usr/bin/mysqldbcompare --server1=root:[email protected]:3306 --server2=root:[email protected]:3306 --run-all-test --changes-for=server2 --difftype=sql test:test1
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.56.101: ... connected.
# server2 on 192.168.56.101: ... connected.
# Checking databases test on server1 and test1 on server2
#
#                                                   Defn    Row     Data   
# Type      Object Name                             Diff    Count   Check  
# ------------------------------------------------------------------------- 
# TABLE     mn1                                     FAIL    FAIL    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  FAIL    
#
# Transformation for --changes-for=server2:
#
 
ALTER TABLE `test1`.`mn1` 
AUTO_INCREMENT=18;
 
# Row counts are not the same among `test`.`mn1` and `test1`.`mn1`.
#
# Transformation for --changes-for=server2:
#
 
INSERT INTO `test1`.`mn1` (`id`, `name`, `address`) VALUES('16', 'dds', 'country4');
INSERT INTO `test1`.`mn1` (`id`, `name`, `address`) VALUES('17', 'dfdds', 'country4');
INSERT INTO `test1`.`mn1` (`id`, `name`, `address`) VALUES('15', 'fdds', 'country4');
INSERT INTO `test1`.`mn1` (`id`, `name`, `address`) VALUES('13', 'fd', 'country4');
INSERT INTO `test1`.`mn1` (`id`, `name`, `address`) VALUES('14', 'fds', 'country4');
 
 
# TABLE     mn2                                     pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     test2                                   pass    FAIL    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# Row counts are not the same among `test`.`test2` and `test1`.`test2`.
#
# The table test2 does not have an usable Index or primary key.
 
# TABLE     test3                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# The table test3 does not have an usable Index or primary key.
 
# TABLE     test4                                   pass    FAIL    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# Row counts are not the same among `test`.`test4` and `test1`.`test4`.
#
# The table test4 does not have an usable Index or primary key.
 
 
# Database consistency check failed.
#
# ...done

2.3.5所有表 数据量完全一致, mn1表一行记录 非主键字段值不一样:

[root@redhat1 ~]# /usr/bin/mysqldbcompare --server1=root:[email protected]:3306 --server2=root:[email protected]:3306 --run-all-test --changes-for=server2 --difftype=sql test:test1
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.56.101: ... connected.
# server2 on 192.168.56.101: ... connected.
# Checking databases test on server1 and test1 on server2
#
#                                                   Defn    Row     Data   
# Type      Object Name                             Diff    Count   Check  
# ------------------------------------------------------------------------- 
# TABLE     mn1                                     pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  FAIL    
#
# Transformation for --changes-for=server2:
#
 
# Data differences found among rows:
UPDATE `test1`.`mn1` SET `name` = 'dfdds' WHERE `id` = '18';
 
 
# TABLE     mn2                                     pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     test2                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# The table test2 does not have an usable Index or primary key.
 
# TABLE     test3                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# The table test3 does not have an usable Index or primary key.
 
# TABLE     test4                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# The table test4 does not have an usable Index or primary key.
 
 
# Database consistency check failed.
#
# ...done

2.3.6无主键表test3 有一行记录值不一致: 非主键表数据量一致,某行记录数据值不一致 无法对比出。

[root@redhat1 ~]# /usr/bin/mysqldbcompare --server1=root:[email protected]:3306 --server2=root:[email protected]:3306 --run-all-test --changes-for=server2 --difftype=sql test:test1
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.56.101: ... connected.
# server2 on 192.168.56.101: ... connected.
# Checking databases test on server1 and test1 on server2
#
#                                                   Defn    Row     Data   
# Type      Object Name                             Diff    Count   Check  
# ------------------------------------------------------------------------- 
# TABLE     mn1                                     pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  FAIL    
#
# Transformation for --changes-for=server2:
#
 
# Data differences found among rows:
UPDATE `test1`.`mn1` SET `name` = 'dfdds' WHERE `id` = '18';
 
 
# TABLE     mn2                                     pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  pass    
# TABLE     test2                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# The table test2 does not have an usable Index or primary key.
 
# TABLE     test3                                   pass    pass    -       
#           - Compare table checksum                                FAIL    
#           - Find row differences                                  SKIP    
#
# The table test3 does not have an usable Index or primary key.
 
 
# Database consistency check failed.
#
# ...done

3.mysqldiff工具:

对比表对象不一致工具

mysqldiff --server1=user:pass@host:port:socket --server2=user:pass@host:port:socket db1.object1:db2.object1 db3:db4
$ mysqldbcompare --server1=user:pass@host:port:socket --server2=user:pass@host:port:socket db1:db2

3.1mysqldiff语法有两个用法:

db1:db2:如果只指定数据库,那么就将两个数据库中互相缺少的对象显示出来,不比较对象里面的差异。这里的对象包括表、存储过程、函数、触发器等。
db1.object1:db2.object1:如果指定了具体表对象,那么就会详细对比两个表的差异,包括表名、字段名、备注、索引、大小写等所有的表相关的对象。
 接下来看一些主要的参数:
 
--server1:配置server1的连接。
--server2:配置server2的连接。
--character-set:配置连接时用的字符集,如果不显示配置默认使用character_set_client。
--width:配置显示的宽度。
--skip-table-options:保持表的选项不变,即对比的差异里面不包括表名、AUTO_INCREMENT、ENGINE、CHARSET等差异。
-d DIFFTYPE,--difftype=DIFFTYPE:差异的信息显示的方式,有[unified|context|differ|sql],默认是unified。如果使用sql,那么就直接生成差异的SQL,这样非常方便。
--changes-for=:修改对象。例如--changes-for=server2,那么对比以sever1为主,生成的差异的修改也是针对server2的对象的修改。
--show-reverse:在生成的差异修改里面,同时会包含server2和server1的修改。
 
/usr/bin/mysqldiff  --server1=root:[email protected]:3306 --server2=root:[email protected]:3306  --changes-for=server2 --difftype=sql test.test4:test1.test4

3.2可对比的内容:

可对比出2个库中的对象个数是否一致;
可对比出2个库中表对象的结构是否一致(多列少列,字段长度,表字符集);
无法对比2个库中的表的数据量;

3.3个人测试

3.3.1一开始2个库数据量完全一致,mn1表一行记录 非主键字段值不一样:

无法对比出 非主键值不一样的数据

[root@redhat1 ~]# /usr/bin/mysqldiff  --server1=root:[email protected]:3306 --server2=root:[email protected]:3306  --changes-for=server2 --difftype=sql test.test4:test1.test4
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.56.101: ... connected.
# server2 on 192.168.56.101: ... connected.
# Comparing test.test4 to test1.test4                              [PASS]
# Success. All objects are the same.
[root@redhat1 ~]# 
[root@redhat1 ~]# /usr/bin/mysqldiff  --server1=root:[email protected]:3306 --server2=root:[email protected]:3306  --changes-for=server2 --difftype=sql test:test1
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.56.101: ... connected.
# server2 on 192.168.56.101: ... connected.
# Comparing `test` to `test1`                                      [PASS]
# Comparing `test`.`mn1` to `test1`.`mn1`                          [PASS]
# Comparing `test`.`mn2` to `test1`.`mn2`                          [PASS]
# Comparing `test`.`test2` to `test1`.`test2`                      [PASS]
# Comparing `test`.`test3` to `test1`.`test3`                      [PASS]
# Comparing `test`.`test4` to `test1`.`test4`                      [PASS]
# Success. All objects are the same.

3.3.2mn1表一行记录 非主键字段值不一样,test.test4表数据量比test1库多:

无法对比数据量差异

[root@redhat1 ~]# /usr/bin/mysqldiff  --server1=root:[email protected]:3306 --server2=root:[email protected]:3306  --changes-for=server2 --difftype=sql test:test1
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.56.101: ... connected.
# server2 on 192.168.56.101: ... connected.
# Comparing `test` to `test1`                                      [PASS]
# Comparing `test`.`mn1` to `test1`.`mn1`                          [PASS]
# Comparing `test`.`mn2` to `test1`.`mn2`                          [PASS]
# Comparing `test`.`test2` to `test1`.`test2`                      [PASS]
# Comparing `test`.`test3` to `test1`.`test3`                      [PASS]
# Comparing `test`.`test4` to `test1`.`test4`                      [PASS]
# Success. All objects are the same.

3.3.3mn1表一行记录 非主键字段值不一样,test.test4 id int(15),test1.test4 id int(11):

能对比出字段长度不一致

[root@redhat1 ~]# /usr/bin/mysqldiff  --server1=root:[email protected]:3306 --server2=root:[email protected]:3306  --changes-for=server2 --difftype=sql test:test1
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.56.101: ... connected.
# server2 on 192.168.56.101: ... connected.
# Comparing `test` to `test1`                                      [PASS]
# Comparing `test`.`mn1` to `test1`.`mn1`                          [PASS]
# Comparing `test`.`mn2` to `test1`.`mn2`                          [PASS]
# Comparing `test`.`test2` to `test1`.`test2`                      [PASS]
# Comparing `test`.`test3` to `test1`.`test3`                      [PASS]
# Comparing `test`.`test4` to `test1`.`test4`                      [FAIL]
# Transformation for --changes-for=server2:
#
 
ALTER TABLE `test1`.`test4` 
  CHANGE COLUMN id id int(15) NULL;
 
# Compare failed. One or more differences found.
[root@redhat1 ~]#

3.3.4test4 字符集不一致, test.test4=utf8 , test1.test4=gbk :

可以对比出字符集区别

[root@redhat1 ~]# /usr/bin/mysqldiff  --server1=root:[email protected]:3306 --server2=root:[email protected]:3306  --changes-for=server2 --difftype=sql test:test1
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.56.101: ... connected.
# server2 on 192.168.56.101: ... connected.
# Comparing `test` to `test1`                                      [PASS]
# Comparing `test`.`mn1` to `test1`.`mn1`                          [PASS]
# Comparing `test`.`mn2` to `test1`.`mn2`                          [PASS]
# Comparing `test`.`test2` to `test1`.`test2`                      [PASS]
# Comparing `test`.`test3` to `test1`.`test3`                      [PASS]
# Comparing `test`.`test4` to `test1`.`test4`                      [FAIL]
# Transformation for --changes-for=server2:
#
 
ALTER TABLE `test1`.`test4` 
COLLATE=utf8mb4_unicode_ci;
# Compare failed. One or more differences found.

3.3.5Test1库中缺少test4表:

[root@redhat1 ~]# /usr/bin/mysqldiff  --server1=root:[email protected]:3306 --server2=root:[email protected]:3306  --changes-for=server2 --difftype=sql test:test1
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.56.101: ... connected.
# server2 on 192.168.56.101: ... connected.
# WARNING: Objects in server1.test but not in server1.test1:
#        TABLE: test4
# Compare failed. One or more differences found.

3.3.6test1.test4表多一列address列:

[root@redhat1 ~]# /usr/bin/mysqldiff  --server1=root:[email protected]:3306 --server2=root:[email protected]:3306  --changes-for=server2 --difftype=sql test:test1
# WARNING: Using a password on the command line interface can be insecure.
# server1 on 192.168.56.101: ... connected.
# server2 on 192.168.56.101: ... connected.
# Comparing `test` to `test1`                                      [PASS]
# Comparing `test`.`mn1` to `test1`.`mn1`                          [PASS]
# Comparing `test`.`mn2` to `test1`.`mn2`                          [PASS]
# Comparing `test`.`test2` to `test1`.`test2`                      [PASS]
# Comparing `test`.`test3` to `test1`.`test3`                      [PASS]
# Comparing `test`.`test4` to `test1`.`test4`                      [FAIL]
# Transformation for --changes-for=server2:
#
 
ALTER TABLE `test1`.`test4` 
  DROP COLUMN address;
 
# Compare failed. One or more differences found.

4.0 总结

mysql-utilities应对mysql5.6 5.7版本使用。但还是用的很少。最后更新时间是2018年6月份。到8.0版本基本被抛弃。有一些情况也可以很好的使用起来。

标签:test1,--,pass,utilities,server2,test,192.168,mysql,一致性
From: https://blog.51cto.com/u_13482808/8273914

相关文章

  • MySQL 单表数据最大不要超过多少行?为什么?
    1背景作为在后端圈开车的多年老司机,是不是经常听到过,“mysql单表最好不要超过2000w”,“单表超过2000w就要考虑数据迁移了”,“你这个表数据都马上要到2000w了,难怪查询速度慢”这些名言民语就和“群里只讨论技术,不开车,开车速度不要超过120码,否则自动踢群”,只听过,没试过......
  • mysql 优化之开启慢查询并分析原因
      第一步.开启mysql慢查询方式一:修改配置文件my.ini增加几行:slow_query_log=on#开启慢查询日志slow_query_log_file=filename#指定日志文件保存路径,不指定的话默认在数据库文件目录下,名为hostname-slow.loglong_query_time=2#指定达到多少秒才算慢查询long-que......
  • mysql常见问题及排查步骤
    问题一:数据库连接串测试报错:Couldnotcreateconnectiontodatabaseserver.504错误遇到数据库问题的通用排查步骤确定数据库没有挂确定远程可以连接(前两个可以通过在本地连接验证)以上都OK,大概率服务器ip被限制访问,如果不是人为限制,在可以访问的服务器连上对应数据库,执行......
  • mysql8.x通过备份文件及binlog日志恢复数据
    问题简述记一次mysql数据库被误删(是整个库被删了)后的还原前提条件数据库版本为mysql8.x以上具有库被删除前的完整备份数据库开启binlog还原步骤第一步:通过完整备份还原被删的库注意事项:还原后切勿让其他用户连接,操作数据库。待使用binlog日志恢复数据后再对库进行操作,否......
  • MySQL到底是 join 性能好,还是in一下更快呢?
    事情是这样的,去年入职的新公司,之后在代码review的时候被提出说,不要写join,join耗性能还是慢来着,当时也是真的没有多想,那就写in好了,最近发现in的数据量过大的时候会导致sql慢,甚至sql太长,直接报错了。这次来浅究一下,到底是in好还是join好,仅目前认知探寻,有不对之处欢迎指正以下实验仅......
  • 记录一次报错,程序启动,MySql自动关闭
    关于初级程序员,对于安装mysql,以及配置可能会报几次错有时候虽然进行第二次安装成功,但是第一次的残留文件还在,可能引起报错在这里记录一次我的报错程序启动导致Mysql自动断开,需要手动打开1、打开任务管理器,打开详细信息,发现界面有两个mysqld.exe如果你是使用单程序连接,或者你......
  • 爬虫-mysql-工具
    MySQL数据库一、MySQL数据库的介绍1、发展史1996年,MySQL1.02008年1月16号Sun公司收购MySQL。2009年4月20,Oracle收购Sun公司。MySQL是一种开放源代码的关系型数据库管理系统(RDBMS),使用最常用的数据库管理语言--结构化查询语言(SQL)进行数据库管理。MySQL是开放源代码的,因此任......
  • Mysql的SQL优化
    1.插入数据环境准备,创建表tb_testcreatetabletb_test(idintnotnullcomment'主键'primarykey,namevarchar(20)nullcomment'姓名',gendercharnullcomment'性别默认1表示男')comment'测试';1.1.inser......
  • Python 数据库应用教程:安装 MySQL 及使用 MySQL Connector
    Python可以用于数据库应用程序。其中最流行的数据库之一是MySQL。MySQL数据库为了能够在本教程中尝试代码示例,您应该在计算机上安装MySQL。您可以在MySQL官方网站下载MySQL数据库。安装MySQL驱动程序Python需要一个MySQL驱动程序来访问MySQL数据库。在本教程中,我们将使用"......
  • Python 数据库应用教程:安装 MySQL 及使用 MySQL Connector
    Python可以用于数据库应用程序。其中最流行的数据库之一是MySQL。MySQL数据库为了能够在本教程中尝试代码示例,您应该在计算机上安装MySQL。您可以在MySQL官方网站下载MySQL数据库。安装MySQL驱动程序Python需要一个MySQL驱动程序来访问MySQL数据库。在本教程中,我们将使用......