Add MB_DB_ENCODING=utf-8 for mysql environment


#1

is it possible to set character-set-server using these environment variables like?
export MB_DB_TYPE=mysql
export MB_DB_ENCODING=utf-8

for example in alfresco:
db.url=jdbc:mysql://localhost/alfresco52f?useUnicode=true&characterEncoding=utf-8&useSSL=false

Current situations:
Metabase version v0.28.5 without setting character-set-server=utf8 for [mysqld] in my.cnf,

the database is default to utf8.
create database metabase default character set utf8;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX,
DROP, CREATE TEMPORARY TABLES, LOCK TABLES
ON metabase.*
TO ‘metabase’@‘localhost’ IDENTIFIED BY ‘Xz=/9ieZ83’;
FLUSH PRIVILEGES;

mysql> show variables like ‘char%’;
±-------------------------±---------------------------+
| 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 | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
±-------------------------±---------------------------+
8 rows in set (0.00 sec)

mysql> show variables like ‘collation%’;
±---------------------±------------------+
| Variable_name | Value |
±---------------------±------------------+
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | latin1_swedish_ci |
±---------------------±------------------+
3 rows in set (0.00 sec)

but the frontend see ?? after save to database;

after add character-set-server=utf8 to [mysqld] in my.cnf ,
this problem solved.


#2

Look at MB_DB_CONNECTION_URI in this post: How to enable SSL for application DB?

If you use that like the example you give with Alfresco maybe that also works for your case of configuring the Metabase application database?


#3

Thanks. It works with out special character passwords.

like this:
export MB_DB_CONNECTION_URI=“mysql://metabase1:9ieZ83l@localhost:3306/metabase1?characterEncoding=utf-8”

this MB_DB_CONNECTION_URI is not in Metabase docs.

Any reserved characters for URLs (for example, /, :, @, (, ), [, ], &, #, =, ?, and space) that appear in any part of the connection URL must be percent encoded.

I add one issue github:


#4

Still think add export MB_DB_ENCODING=utf-8 to environment variables is easier and clear.