• 【MYSQL】MYSQL报错解决方法: Warning: (3719, "'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8M B4 in a future release."


      

      用python3.6.5创建mysql库时出现如下报错,虽然报错,但是数据库可以插入成功。

    D:python3libsite-packagespymysqlcursors.py:170: Warning: (3719, "'utf8' is
    currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 
    in a future release. Please consider using UTF8MB4 in order to be unambiguous.")
      result = self._query(query)
    

      

     解决方法

    •   python版本:3.6.5
    •   mysql版本: 8.0.12

      

      1. 首先查看下mysql字符集

    mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
    +--------------------------+--------------------+
    | Variable_name            | Value              |
    +--------------------------+--------------------+
    | character_set_client     | gbk                |
    | character_set_connection | gbk                |
    | character_set_database   | utf8mb4            |
    | character_set_filesystem | binary             |
    | character_set_results    | gbk                |
    | character_set_server     | utf8mb4            |
    | character_set_system     | utf8               |
    | collation_connection     | gbk_chinese_ci     |
    | collation_database       | utf8mb4_0900_ai_ci |
    | collation_server         | utf8mb4_0900_ai_ci |
    +--------------------------+--------------------+
    10 rows in set, 1 warning (0.04 sec)
    

      

      2. 根据上述查询结果,修改sql语句

    修改前 = 'CREATE DATABASE IF NOT EXISTS database_name DEFAULT CHARSET utf8 COLLATE utf8_general_ci;'
    修改后 = 'CREATE DATABASE IF NOT EXISTS database_name DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;'
    

      DEFAULT CHARSET utf8 COLLATE utf8_general_ci 是之前老版sql的写法。

      

      代码执行创建成功~(๑•̀ㅂ•́)و✧

      

      相关知识补充

      UTF8MB4与UTF8MB3的区别介绍:https://dev.mysql.com/doc/refman/5.6/en/charset-unicode-utf8mb4.html

  • 相关阅读:
    Android开发:关于WebView
    PHP+JQUEY+AJAX实现分页
    Bootstrap入门(二)栅格
    BootStrap入门教程 (一)
    mac 终端命令
    没有功能需求设计文档?对不起,拒绝开发!
    React 入门教程
    Webpack+React+ES6开发模式入门指南
    webpack2.0+ vue2.0
    一个小时学会jQuery
  • 原文地址:https://www.cnblogs.com/lilip/p/10109557.html
Copyright © 2020-2023  润新知