Unknown character set: 'utf8mb4' - mysql

im trying to upload my first wordpress website. Im using the local wordpress.org php my admin and the php my admin from 000webhost. Ive researched this a a lot here and changed all the settings people were saying from utf8mb4 to utf8 but it only caused more errors. I changed everything back to what it was (at least i think so and the error is the same as the beginning now). Anyone knows how i can get around this and import my db to 000.webhost with no errors? the Error is SQL query:
/*!40101 SET NAMES utf8mb4 */;
and
MySQL said: Documentation
1115 - Unknown character set: 'utf8mb4'

1) The first: If you can control ssh server. Please update mysql version. Your mysql too old. Maybe < 5.5.3.
2) The second: If you can't access ssh. Try to export your database with Mysql version 4.0.
With command line mysqldump --compatible=mysql40 -u user -p DB > dumpfile.sql
With web access phpmyadmin -> Select Database -> Export -> Custom - display all possible options -> Format-specific options ->
Database system or older MySQL server to maximize output compatibility with: Select MYSQL40.
Change content file .sql you exported
/*!50003 SET character_set_client = utf8mb4 */ ;
to utf8 only.
And replace by Ctrl H in Sublime change all from utf8mb4 => utf8
Hope this helps.

Just modify this into mysql Database.
wrong that modify ..... /*!40101 SET NAMES utf8mb4 /;
now corrected ..... /!40101 SET NAMES utf8 */;
just erase .... mb4 ....
its work now

Related

character encoding issues when migrating gyroscope app from mysql (latin1) to mariadb (utf8)

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

Unknown character set: 'utf8mb4'

I know that many had this problem, and solved it, but even with their solutions, I've gotten no luck..
I tried exporting my localhost phpadmin to my webserver, and i got:
SQL query:
/*!40101 SET NAMES utf8mb4 */;
MySQL said: Documentation
#1115 - Unknown character set: 'utf8mb4'
Local phpmyadmin:
Server type: MariaDB
Server charset: UTF-8 Unicode (utf8)
Version: 4.5.2
Webhost phpmyadmin:
Version: 2.11.4
Solved it. Downloaded MYSQL workbench, logged into my local database, and exported it from the program. Then, i simply imported the file, and it worked!

Character set and collation in database

I am a beginner when it comes to databases, so please bear with me. I'm trying to set up a database and import some tables from a file tables.sql. Some of the Columns in tables.sql have Swedish letters in them (Ä, Ö) and the problem is that I get the following:
Ä = ä
Ö = ö
First I begin to check the character set of the server:
mysql> show variables like 'character_set_server';
The server is configured to character set 'Latin-1'. I must mention that I have no control over the server more than to create a database. So I guess I have to create my database and specify the character set of the database.
This is how I proceed:
mysql> create database db;
mysql> alter database db character set utf8 collate utf8_swedish_ci;
I double checked that my tables.sql have charset utf-8 by executing:
file -bi allsok_tables.sql
And then I load it into the database by:
$ mysql -u [username] -h [hostname] -P [port] -p db < tables.sql
when I create my tables in tables.sql I use engine = InnoDB (don't know if this is relevant or not). However if I now select everything from the table TableTest
mysql> select * from TableTest
I get these weird characters instead of the Swedish characters. I appreciate any help right now.
Thanks in advance!
UPDATE:
If I insert a value manually into a table it works e.g.
mysql> insert into TableTest values ('åäö');
So the problem seems to be with the .sql-file. Right?
$ mysql ... --default-character-set=utf8 < tables.sql
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
MySQL needs to know what encoding the data you're sending it is in. To do this, you need to set the connection encoding. When connecting to MySQL from a client, you usually run a SET NAMES query or use an equivalent call on your API of choice to do so. On the command line, the --default-character-set option does this. It needs to be set to whatever encoding your file is in.

MySQL UTF8 Windows export - Linux import

I have MySQL database version 5.1.36, that came with WAMP installation. I used it for development purposes on Windows XP SP3, and it has some data in it, which is cyrillic, and the collation for all of those tables/columns is set to utf8_general_ci.
Now the time has come to move this database to pseudo-production environment, which is on Debian Lenny. Version of MySQL here is 5.0.51a.
I tried the following:
I exported the databse with data from phpmyadmin on Windows and saved the .sql file to be in UTF8.
Then, I transferred it through WinSCP (both with default and binary transfer settings) to Linux machine.
I created the database through command line: mysqladmin -u root -p create nbs
Finally, I tried to create tables and fill the data:
mysql -u root -p --default-character-set=utf8 nbs < NBS_utf8_1.sql
However, this is where I'm getting the error, like:
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
CREATE TABLE IF NOT EXISTS `history_members` (
`id` int(11) NOT NULL AUTO_' at line 1
Something is messed up with encoding, I suppose... but don't know how and where. I think I read in the similar question on SO that binary mode for text transfer will only change the line breaks CRLF to LF (don't know if this is correct...). What am I missing here?
Thanks.
For this particular case, the problem was solved with the following modifications:
1) I set initial collation while creating the target database to utf8_general_ci,
2) I transferred the file with text mode through WinSCP,
3) I added SET NAMES 'utf8' COLLATE 'utf8_general_ci'; to the top of sql dump.
Here is what I found using PhpMyAdmin for a rough SQL import using remote shell :
/*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */;
/*!40101 SET #OLD_CHARACTER_SET_RESULTS=##CHARACTER_SET_RESULTS */;
/*!40101 SET #OLD_COLLATION_CONNECTION=##COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

Can not insert UTF8 to Database MySQL in Linux

When create table, I have setted charset = utf8.
I create 1 store procedure to insert data to database.
When insert data UTF8 to Database on Window, it works OK.(Display data correctly)
But it doesnot work in Linux.(Display data not correctly)
The strange thing is insert UTF8 work fine in window, but when i deploy MySQL in linux, when insert data to database it insert wrong UTF8 value.
Thanks for help
Edit: Update more detail follow comment of #Col. Shrapnel
You should start mysql console with --default-character-set=utf8:
mysql --default-character-set=utf8 -uyour_user -p
most probably you didn't specify client character set by issuing SET NAMES UTF8 query
but there can be other problems - your database or a web page may be not in the utf-8
I just found a solution for my problem: Edit file my.cnf under /etc/my.cnf as below:
[mysqld]
default-character-set=utf8
default-collation=utf8_general_ci
character-set-server=utf8
collation-server=utf8_general_ci
init-connect='SET NAMES utf8'
[client]
default-character-set=utf8
But i still confuse why this bug occur in Linux, not in Window.