分享

MySql问题笔记整理

 笑笑兔 2023-09-27 发布于天津

1、in 条件排序

SELECT * from `users` where `id` in (26612,26611,26610) order by field(id,26612,26611,26610);

2、mysqldump: Got error: 1356 mysqldump

mysql表删除,视图未关联删除报错!

mysqldump: Got error: 1356: View 'Student.v_score' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them when using LOCK TABLES

解决方法:$mysqldump -ubkpuser -ps3cret  --force  wordpress  >wordpress1.sql

3、mysql去除小数点后面0

将0.2000转换为0.2

mysql> select 0 + CAST(0.20000 AS CHAR );

4、解决sql_mode=only_full_group_by

mysql 5.7 版本及以上版本会出现的问题:
     mysql 5.7版本默认的sql配置是:sql_mode="ONLY_FULL_GROUP_BY",这个配置严格执行了"SQL92标准"。
   很多从5.6升级到5.7时,为了语法兼容,大部分都会选择调整sql_mode,使其保持跟5.6一致,为了尽量兼容程序。

解决方法:

在my.ini配置文件添加[mysqld]下面添加

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

5、jdbc连接mysql报错:The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration。

解决方法:

完整的连接字符串示例:jdbc:mysql://localhost:3306/test?serverTimezone=UTC

或者还有另一种选择:jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8,这个是解决中文乱码输入问题,当然也可以和上面的一起结合:jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC





    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多