Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Closed Points: 200 Time: 06:17 - Feb 16, 2007  

jgivoni

MySQL command line import of file with UTF-8 encoding.

I am having trouble with an .sql file containing a backup of a database which will be used to restore the database daily.

The way I am executing the restore process is by using the mysql command (batch mode - linux shell):
mysql < origdata.sql

This works perfectly if the .sql file itself is encoded with default (ISO-????) character set, but when working with more exotic languages I have to use UTF-8. Saving the file in UTF-8 encoding is not working, since mysql doesn't know that it is UTF-8 and interprets it as default encoding, thus messing up a lot of forreign characters.

My question is, if there is a way to let mysql know that this file should be interpreted as UTF-8?
Either by
1) specifying the encoding on the command line
2) specifying the encoding within the file
3) specifying the encoding at filesystem level (I am not so clear here, but something like headers for http)

Note that this problem has nothing to do with the charset or collation of the database itself, nor with the database connection (these all work perfectly with UTF-8) only the command line import utility.

Please come forward if you know anything about this!

Jakob

Answer Discussion
Tutorials

 

mail

Date:: Mar 13, 2007

Time:: 10:15

mysql -h host -u username -p password -default_character_set utf8 database < file.sql

cheers

jgivoni

Date:: Mar 15, 2007

Time:: 04:32

Thanks!
That command line parameter actually works - well, you have to use double dash (--) like this:

mysql -h host -u username -p password --default_character_set utf8 database < file.sql

Silly me hadn't tried it before because I'd read in a forum that it only applies to the connection and the database - not the file :-) Maybe that was true in a previous version of mysql...
Now it works!

RABINGHOSHNTPL

Date:: Apr 06, 2010

Time:: 11:24

.SQL DATA IMPORT PROBLEM. HOW TO IMPORT .SQL TABLE IN DATABASE.

Question Answered

This question has been closed, and points have been rewarded to the following experts:


mail: 200

You're welcome however to comment or give additional information or if you wish, you have the ability to write a Tutorial in the Tutorial Area.

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

No tutorials have been submitted yet. Want to be the first?

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10354

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es