Upon creating a database from the mysql command line with character sets, I get the following error: Unknown character set: utf8_unicode_ci. But, when I run the same SQL in phpmyadmin, it works fine with no errors and I cant figure out why?
The SQL:
CREATE DATABASE sx CHARACTER SET =utf8 COLLATE = utf8_unicode_ci;
mysql command line:
mysql -u root -ppassword -h localhost --default-character-set=utf8
Since you're getting the error Unknown character set: 'utf8_unicode_ci', you must be specifying utf8_unicode_ci (which is a collation) as the character set. Check your command and try again.
Change your DB_CHARSET utf8_general_ci to utf8
Related
I have a mysql database in Gcloud using utf8 enconding and I want to change it to utf8mb4 to support storing emoticons.
I did this using my local version of mysql in my laptop and it worked fine using:
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER DATABASE db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
But when I try to do the same in Gcloud, the commands are accepted and the encoding changes but I keep receiving this error when trying to insert the record:
"error": "could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement: Incorrect string value: '\xF0\x9F\xA6\x95' for column 'text' at row 1" }
I also changed character_set_server variable in gcloud to utf8mb4 and restarted the engine but it does not work. Does anybody know what else should I change?
Thanks!
I'm migrating a small Gyroscope app from MySQL to MariaDB. I asked this question earlier on why MariaDB would not start on latin1 as server encoding (MariaDB won't start when character-set-server = latin1 is in my.cnf), but now I've come to terms with using just utf8.
After importing the data dump:
mysql -uwebuser -p ezine < dump.sql
, what's supposed to be autotööstus shows up as autot??stus. In addition I got this error:
illegal mix of collations (latin1_general_ci implicit) and (utf8_general_ci coercible), storing ??
Attempt 1: I removed all the occurrences of charset=latin1 in the data dump, and the import terminated early with this error:
Specified key was too long; max key length is 767 bytes
Attempt 2: added back charset, but set it to charset=utf8, according to this post: MySQL Convert latin1 data to UTF8
The import works, but autotööstus is now showing as autotööstus
How do I interpret the data dump as latin1 encoded content but deposit into a utf8 storage?
If you cannot use latin1 as the default system encoding for whatever reason, here's a quick solution:
Leave the data dump as-is. Even though it's latin1 encoded, it can be imported as utf8.
mysql> create database ezine character set utf8 collate utf8_general_ci;
mysql -uwebuser -p --default-character-set=utf8 ezine < dump.sql
Now in your web app, you should correctly see autotööstus
From now on, the "native currency" of your database is utf8. When dumping the database, you have to be careful, make sure the exported file is still latin1 encoded.
Otherwise you'll end up with the over-encoded data, such as autotööstus.
mysqldump -uwebuser -p --default-char-set=latin1 ezine > dump.sql
I getting this error
django.db.utils.OperationalError: (1366, "Incorrect string value:
'\xF0\x9F\x99\x8F \xF0...' for column 'html_code' at row 1")
I created database using this command
CREATE DATABASE sample CHARACTER SET utf8;
I have these settings in mysql
vim /etc/mysql/conf.d/mysql.cnf
[mysql]
default-character-set=utf8mb4
vim /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
I even used this command as well
ALTER TABLE sample_randy CONVERT TO CHARACTER SET utf8
The problem is it worked first time i use those command and after sometime it again stop working with same error.
I am not sure which thing is resetting the options
If i delete the database, create again and run script again then it work again. if i rerun again then it get same error
To get the character for 'PERSON WITH FOLDED HANDS', you needed utf8mb4 (not just utf8) everywhere. Do
ALTER TABLE sample_randy CONVERT TO CHARACTER SET utf8mb4
After changing the collation in phpmyadmin for several databases, I can't see them anymore in chrome and explorer. If a use the command SHOW DATABASES in the command line, they are all displayed.
In Firefox, the following error is thrown:
SET CHARACTER SET 'utf8mb4';
1115 - Unknown character set: 'utf8mb4'
This is my first post, any help would be appreciated.
Edit:
I had already read Q&A in ERROR 1115 (42000): Unknown character set: 'utf8mb4', but it didn't solve my problem.
The mysql version I'm using is 5.6.17, and the character set is supported from version 5.3.3, so updating wouldn't help. I'm using wamp 2.5 with Mysql 5.6.17, Apache 2.4.9 and PHP 5.5.12.
And I get the error simply accessing http://localhost/phpmyadmin (not executing any sql) after my update, so the problem seems to be already commited. It's quite confusing that the error message is displayed only in Firefox while other browsers simply hide some databases and show the others.
Executing 'SELECT default_collation_name FROM information_schema.SCHEMATA;' in command line brought me these results:
utf8_general_ci
utf8_general_ci
utf8_spanish_ci
utf8_general_ci
utf8_general_ci
utf8_spanish_ci
utf8_general_ci
utf8_spanish_ci
utf8_general_ci
latin1_swedish_ci
utf8_spanish_ci
utf8_general_ci
utf8_general_ci
utf8_general_ci
utf8_general_ci
latin1_swedish_ci
utf8_general_ci
utf8_general_ci
utf8_general_ci
utf8_general_ci
utf8_general_ci
utf8_general_ci
In PhpMyAdmin, the SCHEMATA table only shows ¡three! results:
One for 'information_schema', another for 'mysql' and the last one for one of my databases. The others are not there.
After some research, I discovered there where two instances of mysql running on my server.
Phpmyadmin was using a 32 bits old version while the mysql command line was linked to the 64 bits one. I stopped the old one and now everything runs ok.
At shell command prompt:
mysqladmin -u"username" -p"password" --default-character-set=utf8 CREATE my_db_schema
--default-character-set=utf8 seems to have no effect and I don't understand why.
Database gets created, but character set is latin1 with collation latin1_swedish_ci.
I found this question, which would seem to be the same issue, but even when I tried a non-root user as the selected answer suggested, I get identical behavior:
MySQL connection character set problems
(I'm using Windows and MariaDB if that makes any difference)
I have tried these mysqladmin.exe clients:
MariaDB 5.3.2 for Win32 (ia32) with default character set latin1 (no .ini)
MySQL 5.0.77 for linux-gnu (i686) with default character set utf8
In both cases, --default-character-set=utf8 or --default-character-set=latin1 do NOT override the MySQL server's .ini/.cnf settings.
As a workaround I'd suggest running:
echo "CREATE DATABASE my_db_schema DEFAULT CHARACTER SET utf8" | mysql -uusername -ppassword
--default-character-set=utf8 seems to have no effect and I don't understand why.
Database gets created, but character set is latin1 with collation latin1_swedish_ci.
This options does not influence the character of a datatabase, table or column when they are created.
The default-character-set is the character set of the connection to the server -- it ensures values you select from the database come through to the client with the correct encoding for display.
On the surface I'd say this appears to be a mysqladmin bug. I would let the MariaDB devs know about it.
http://kb.askmonty.org/en/reporting-bugs has general instructions about reporting bugs (ignore the bit about using the mysqlbug script, since it is not available on Windows).
P.S. And if the bug exists in MariaDB it likely also exists in MySQL.