I'm trying to dump a heroku db with heroku db:pull
The problem is that the data that has special character (like 'ñ') are not store propertly.
I see that the local tables are created with default charset=latin1
is there a way that the heroku script create the table with charset utf8?
heroku db:push -t tables mysql://user:pass#localhost/mydb encoding=UTF8 --confirm myapp
The solution is to set the default charset in mysql server itself like in:
Change MySQL default character set to UTF-8 in my.cnf?
doing that and after restart the local mysql, heroku db:pull will create the tables with the default utf8 charset.
Related
While upgrading mysql from 5.6 -> 5.7 -> 8.0.23 in step 5.7 -> 8.0.23 I got a recommendation:
The following objects use the utf8mb3 character set. It is recommended to convert them to use utf8mb4 instead, for improved Unicode support.
More Information:
https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb3.html
...
mysql - schema's default character set: utf8
...
So, Is it enough to change the charset of the schema mysql to utf8mb4? Or at first, does it need to convert all the tables of this schema to utf8mb4?
The way to change a schema's default characters set:
ALTER SCHEMA mysql DEFAULT CHARACTER SET utf8mb4;
However, I don't know if your admin user on RDS has privileges to do that on the mysql system schema. It's possible that you don't, because RDS limits the privileges of your admin user.
I'm running ubuntu 14.04 and flyway doesn't seem to be able to read my UTF-8 encoded SQL script.
I can run the sql script by using the terminal command
mysql -u root -p my_db < v1_1__Test_migration_script.sql
But when flyway runs it, I get the error Incorrect string value: on the file that is UTF-8 encoded.
My system has LANG set as en_US.UTF-8
Note that when flyway runs during setup on my Mac OSX machine it all works fine.
The issue was that the database was using a different character set and collation.
A fix that worked for me was to specify it explicitly
CREATE DATABASE my_db DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
I have a database set up to use the encoding UTF-8 multibyte-4. This is configured in the my.cnf file:
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
(...)
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
I would like to add a 2nd database, let's call them DB1 and DB2.
The problem: The application that uses this 2nd database DB2 cannot work with the encoding I have configured in my.cnf. It's a 3rd party application, so I have no possibility to change something, all I can do is modify the databse setup.
If I comment the above lines in my.cnf, the 3rd party application works, I guess it's using plain UTF-8 encoding. But now the system using the 1st database DB1 fails on encoding.
Is there a way to specify a default encoding in my.cnf for each database, separating DB1 encoding from DB2? Searching the internet has not shown me any solution other than using a separate/2nd MySQL installation.
Using MySQL version 5.6.x
Any hints are greatly appreciated.
Shoot that 3rd party software.
Have utf8 in my.cnf. Perform SET NAMES utf8mb4; in that applications that need it and that you can get to.
I have PHP 5.5.9 and MySQL 5.5.43 Innodb. This is in Kubuntu LTS /etc/mysql/my.cnf
printf("Current character set: %s\n", mysqli_character_set_name($conn));
Current character set: latin1
I've tried
default-character-set = utf8
first but then my mysql server didn't restart
Then I've tried
character-set-server = utf8
then my mysql shell didn't start
How can I rescue this issue? I've managed with
init_connect = 'SET NAMES utf8'
solve the problem for nonroot users, but the charset remains the same (it only displays as nonprivileged users UTF8, it is still Latin1).
And if (a big if) smnd could tell me WHERE should I use utf8mb4? Also in my.cnf file? I had my tables in utf8 and have migrated those with which I am working to utf8mb4 ...
Another Q: IS that applicable for Linux (Kubuntu) server:
https://www.youtube.com/watch?v=3M1Wpw4uOoM
Please help me, thanks, Gregor from lilaum.com
mysqli_set_charset('utf8').
init_connect is ignored for root connections.
utf8mb4 is effectively a superset of utf8. It is needed for Chinese and the new emoji, plus a scattering of obscure character sets.
PHP manual says:
MySQLnd always assumes the server default charset. This charset is sent during connection hand-shake/authentication, which mysqlnd will use.
MySQLnd is the MySQL native driver included with PHP 5.4 and above.
Unfortunately, I have to confirm that even in my system (PHP 5.6.17 with MySQL 5.5.47 on Debian Jessie 8.3) despite having configured /etc/mysql/my.cnf with the following entries
[mysqld]
character-set-server=utf8
[mysql]
default-character-set=utf8
the mysqlnd does not seem to assume the server default charset (utf8) but sets the connection charset to latin1 with collate latin1_swedish (maybe a default value considering MySQL AB was a swedish company).
So, it seems that there's no permanent way to set utf8 charset when connecting from a PHP application. You have to call
$mysqli->set_charset("utf8")
after each connection. This could be embedded in a custom 'dbconnect' PHP function in order to provide a sort of abstraction layer.
I need to change the default charset of MySQL. I want the new database and all tables to use UTF-8. When I create django unit tests, the tests fail while creating the DB because it is set to latin1.
I can't do that in my.cnf. I use Ubuntu and MySQL installed from repository.
create database `something` default charset=utf8;
http://dev.mysql.com/doc/refman/5.0/en/create-database.html
Try:
# Alter your database
ALTER DATABASE database_name DEFAULT CHARSET=utf8;
SHOW CREATE DATABASE database_name;
CREATE DATABASE `zzz_test` /*!40100 DEFAULT CHARACTER SET utf8 */