LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-18-2011, 04:02 AM   #1
ddaas
Member
 
Registered: Oct 2004
Location: Romania
Distribution: Ubuntu server, FreeBsd
Posts: 474

Rep: Reputation: 30
mysqldump: special chars are not correctly saved


Hello,
I have some tables that contain special characters from different languages like German, Italian, Russian, Spanish etc. They are stored and displayed correctly.

When want to backup my DB like "mysqldump -h localhost-u root -p dbname > dbname.sql"
the special characters are lost, they are not correctly stored nor displayed in the sql file. This means there is no possible restoration.

How can dump the tables in the right way? I think this is a very common problem.


Thank you
 
Old 02-18-2011, 10:57 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 270Reputation: 270Reputation: 270
No, it's not common, most people learn or read what options to use during the mysqldump to preserve special characters.

It would probably look something more like this during the mysqldump:

Code:
mysqldump -u root -p --default-character-set=latin1 dbname > dbname.sql
Then when you import the database, you need to possibly specify utf8 as the default character or change it (latin1) after it's imported in the dump file, would look something like this:

Code:
/*!40101 SET NAMES latin1 */;
Change that latin1 to utf8, then import the dump file.
 
Old 02-18-2011, 03:14 PM   #3
ddaas
Member
 
Registered: Oct 2004
Location: Romania
Distribution: Ubuntu server, FreeBsd
Posts: 474

Original Poster
Rep: Reputation: 30
Thank you.
I'll do the tests and let everybody know how it works.
 
Old 02-23-2011, 09:07 AM   #4
ddaas
Member
 
Registered: Oct 2004
Location: Romania
Distribution: Ubuntu server, FreeBsd
Posts: 474

Original Poster
Rep: Reputation: 30
The database had both utf8 and latin1 columns for some tables.
I can backup and restore successfully using: mysqldump -u root -p --default-character-set=utf8 dbname > dbname.sql

Then I can replace everywhere in the dump file latin1 with utf8 and the restoration is correct. Also all the columns are now utf8.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in replacing special chars using awk linux_vidhyarthi Linux - General 2 04-09-2008 08:39 PM
bash, filenames, special chars zomane Programming 3 06-15-2007 05:55 AM
Problem with special chars in general smokylux Linux - General 6 05-26-2004 05:46 AM
German umlaute (special chars) in file system steltner Linux - General 5 10-27-2003 03:07 PM
telnet and special chars csDraco_ Slackware 7 05-21-2003 10:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration