data porting in mysql - mysql

While porting data from one mysql database to another there have come some issues like appostrophes have been converted into †in a field called story. Why did this happen and what should I do now to correct the new database?
I have only the phpmyadmin access of the two databases.

Take a look at the charatersets used by your database. You can do this by entering \s in the MySQL client. Example output is:
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
What charactersets do you get and what do you expect?

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

mysql change default character set latin1 to utf8

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.

foreign character è is not saving in mysql

the name "Eugène" became "EugÃ?ne". Please, give me a solution. I tried before by changing db character set but, still not working.
Connection id: 2939
Current database: clcdb_final
Current user: root#localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.5.32-log MySQL Community Server (GPL) by Remi
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 45 min 59 sec
and table info: ENGINE=MyISAM AUTO_INCREMENT=57431 DEFAULT CHARSET=latin1
Just check mySql connector jar version. if you using back dated jar then this can be happen.
Verify that you have specified
"charset=utf8"
in your connection string.
As noted in Character Sets and Collations in General
MySQL can do:
Store strings using a variety of character sets
Compare strings using a variety of collations
Mix strings with different character sets or collations in the same server, the same database, or even the same table
Allow specification of character set and collation at any level
Verify that:
"charset=utf8"
And
Collation ==> utf8 - utf8_bin

UTF8 characters not showing correctly in Wordpress

I am running out of ideas - Wordpress is refusing to save UTF-8 encoded characters correctly:
http://www.letosanezkou.com/
you can see that when I edit the post content directly in the MySQl DB it works correctly. I have verified the mysql db:
mysql Ver 14.14 Distrib 5.5.24, for Linux (i686) using readline 5.1
Connection id: 2120
Current database: leto_wp1
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.5.24-cll MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
and my wp-config has the default UTF-8 lines:
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
When I try to update the post, that was edited in phpmyadmin it will save the post incorrectly.
Any ideas on how to fix this please?

Question with mysql characterset

I notice that there are kinds of charactersets in mysql, for instance:
Server characterset: latin1
Db characterset: utf8
Client characterset: utf8
Conn. characterset:
So I want to know what is the difference between them? thanks!
http://en.wikipedia.org/wiki/Character_encoding
If you want to use different encodings, you have to do some transformations. PHP has some functions for this.