MySQL8.0修改lower_case_table_names参数导致重启失败

​事件起因:在测试一个数据迁移工具时,源端oracle19c数据迁移到目标端MySQL8.0,提示迁移目标端  Unknown database 'SBTEST',报错如下:

2022-07-29 10:08:19,155 ERROR com.greatsync.connector.jdbc.internal.ComplexJdbcOutputFormat [] - JDBC executeBatch error, retry times = 0
java.sql.BatchUpdateException: Unknown database 'SBTEST'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_312]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_312]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_312]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_312]
at com.mysql.cj.util.Util.handleNewInstance(Util.java:192) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.util.Util.getInstance(Util.java:167) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.util.Util.getInstance(Util.java:174) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.exceptions.SQLError.createBatchUpdateException(SQLError.java:224) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.ClientPreparedStatement.executeBatchedInserts(ClientPreparedStatement.java:755) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.ClientPreparedStatement.executeBatchInternal(ClientPreparedStatement.java:426) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.StatementImpl.executeBatch(StatementImpl.java:795) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.greatsync.connector.jdbc.statement.FieldNamedPreparedStatementImpl.executeBatch(FieldNamedPreparedStatementImpl.java:77) ~[blob_p-90078b57fb2c51eb5935c045d2e493ef0a7d1524-e9c0e1166eea1bd94ba3d5a23c03b9b3:?]
at com.greatsync.connector.jdbc.internal.executor.TableSimpleStatementExecutor.executeBatch(TableSimpleStatementExecutor.java:63) ~[blob_p-90078b57fb2c51eb5935c045d2e493ef0a7d1524-e9c0e1166eea1bd94ba3d5a23c03b9b3:?]
at com.greatsync.connector.jdbc.internal.executor.TableBufferReducedStatementExecutor.executeBatch(TableBufferReducedStatementExecutor.java:121) ~[blob_p-90078b57fb2c51eb5935c045d2e493ef0a7d1524-e9c0e1166eea1bd94ba3d5a23c03b9b3:?]
at com.greatsync.connector.jdbc.internal.ComplexJdbcOutputFormat.attemptFlush(ComplexJdbcOutputFormat.java:243) ~[blob_p-90078b57fb2c51eb5935c045d2e493ef0a7d1524-e9c0e1166eea1bd94ba3d5a23c03b9b3:?]
at com.greatsync.connector.jdbc.internal.ComplexJdbcOutputFormat.flush(ComplexJdbcOutputFormat.java:210) ~[blob_p-90078b57fb2c51eb5935c045d2e493ef0a7d1524-e9c0e1166eea1bd94ba3d5a23c03b9b3:?]
at com.greatsync.connector.jdbc.internal.ComplexJdbcSinkFunction.lambda$open$0(ComplexJdbcSinkFunction.java:63) ~[blob_p-90078b57fb2c51eb5935c045d2e493ef0a7d1524-e9c0e1166eea1bd94ba3d5a23c03b9b3:?]
at org.apache.flink.streaming.runtime.tasks.StreamTask.invokeProcessingTimeCallback(StreamTask.java:1693) ~[flink-dist_2.11-1.14.4.jar:1.14.4]
at org.apache.flink.streaming.runtime.tasks.StreamTask.lambda$null$22(StreamTask.java:1684) ~[flink-dist_2.11-1.14.4.jar:1.14.4]
at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.runThrowing(StreamTaskActionExecutor.java:50) ~[flink-dist_2.11-1.14.4.jar:1.14.4]
at org.apache.flink.streaming.runtime.tasks.mailbox.Mail.run(Mail.java:90) ~[flink-dist_2.11-1.14.4.jar:1.14.4]
at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMailsNonBlocking(MailboxProcessor.java:353) ~[flink-dist_2.11-1.14.4.jar:1.14.4]
at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.processMail(MailboxProcessor.java:317) ~[flink-dist_2.11-1.14.4.jar:1.14.4]
at org.apache.flink.streaming.runtime.tasks.mailbox.MailboxProcessor.runMailboxLoop(MailboxProcessor.java:201) ~[flink-dist_2.11-1.14.4.jar:1.14.4]
at org.apache.flink.streaming.runtime.tasks.StreamTask.runMailboxLoop(StreamTask.java:809) ~[flink-dist_2.11-1.14.4.jar:1.14.4]
at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:761) ~[flink-dist_2.11-1.14.4.jar:1.14.4]
at org.apache.flink.runtime.taskmanager.Task.runWithSystemExitMonitoring(Task.java:958) [flink-dist_2.11-1.14.4.jar:1.14.4]
at org.apache.flink.runtime.taskmanager.Task.restoreAndInvoke(Task.java:937) [flink-dist_2.11-1.14.4.jar:1.14.4]
at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:766) [flink-dist_2.11-1.14.4.jar:1.14.4]
at org.apache.flink.runtime.taskmanager.Task.run(Task.java:575) [flink-dist_2.11-1.14.4.jar:1.14.4]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_312]
Caused by: java.sql.SQLSyntaxErrorException: Unknown database 'SBTEST'
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1098) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1046) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1371) ~[mysql-connector-java-8.0.28.jar:8.0.28]
at com.mysql.cj.jdbc.ClientPreparedStatement.executeBatchedInserts(ClientPreparedStatement.java:716) ~[mysql-connector-java-8.0.28.jar:8.0.28]
... 22 more

于是查看了目标端MySQL的Databases:

mysql> select @@version,@@default_storage_engine;
+-----------+--------------------------+
| @@version | @@default_storage_engine |
+-----------+--------------------------+
| 8.0.29 | InnoDB |
+-----------+--------------------------+
1 row in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sbtest |
| sys |
+--------------------+
5 rows in set (0.01 sec)
--使用大写的database name,报错
mysql> use SBTEST
ERROR 1049 (42000): Unknown database 'SBTEST'
--使用小写的database name,可以正常访问
mysql> use sbtest
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

发现目标端是存在sbtest这个库,但是只能小写访问,继续检查大小写敏感配置

mysql> select @@lower_case_table_names;
+--------------------------+
| @@lower_case_table_names |
+--------------------------+
| 0 |
+--------------------------+
1 row in set (0.00 sec)

可见目标端的MySQL8.0未开启忽略大写的配置,Oracle的对象名称默认是大写,迁移工具迁移时未进行对象名称转小写,导致迁移失败,程序报错 这时的想法那手动改下lower_case_table_names不就行了,于是就有了如下的操作:修改MySQL配置文件:

#my.cnf配置中增加如下配置
lower-case-table-names=1

重启我的MySQL8.0 docker容器并查看日志:

root@mysql:~# docker restart mysql8.0.29 
mysql8.0.29
root@mysql:~# docker logs -f mysql8.0.29
2022-07-29 02:28:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1debian10 started.
2022-07-29 02:28:48+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-07-29 02:28:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1debian10 started.
2022-07-29T02:28:48.532695-00:00 0 [Warning] [MY-011068] [Server] The syntax 'log_slave_updates' is deprecated and will be removed in a future release. Please use log_replica_updates instead.
2022-07-29T02:28:48.532736-00:00 0 [Warning] [MY-010097] [Server] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2022-07-29T02:28:48.532776-00:00 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2022-07-29T02:28:48.532794-00:00 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.29) starting as process 1
2022-07-29T02:28:48.541090-00:00 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-07-29T02:28:50.875623-00:00 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-07-29T02:28:50.896028-00:00 1 [ERROR] [MY-011087] [Server] Different lower_case_table_names settings for server ('1') and data dictionary ('0').
2022-07-29T02:28:50.896513-00:00 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-07-29T02:28:50.897228-00:00 0 [ERROR] [MY-010119] [Server] Aborting
2022-07-29T02:MySQL8.0修改lower_case_table_names参数导致重启失败
文章起源:http://www.csdahua.cn/qtweb/news35/421735.html

网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 快上网