查看数据库当前编码【Mariadb、Mysql、Flask】

情景

在centos下部署flask项目,使用的是mariadb,(本地mysql香香的),用到sqlarchemy,插入前中文,出入后查询乱码,最终定位在数据库上,

排查
mysql>show variables like 'character%';

创建时定义好数据库字符

//这里创建一个名为BEvents的数据库
create database BEvents default charset utf8 collate utf8_general_ci;
MariaDB [BEvents]> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)
这次没有出现latin-1,运行也没有出现乱码,3h,呜呜呜。

你可能感兴趣的:(Flask,Mysql,sqlite,专栏,Linux,Ubuntu,CentOS,专栏)