I'm new to MySQL. I am interested how to do this via command line; I've tried but I get NO logging in the console output and the character set is not utf-8.
3 Answers
mysql -e "source /path-to-backup/backup-file.sql" db_name
or
mysql db_name < backup-file.sql
You probably need -u username -p, too in your command.
6 Comments
Nam G VU
I've tried
mysql db_name < backup-file.sql but utf-8 data are lostJacob
Did you try both, is the correct data in the SQL file to begin with?
Kerrek SB
Unicode? UTF-8? What's it going to be? Anyway, how does the sql file start? Files created with
mysqldump contain all the relevant parameters to set the necessary encoding options, I believe; is your file a straight dump file?Nam G VU
@Kerrek This is my sample script in utf8 db.tt/IyNbFAj. Have tried successful using
Navicat execute sql filebut running from commandline failedKerrek SB
Ah, your script is missing any character set configuration commands... (take a look at the result of
mysqldump to see what I mean). You could try passing --default-character-set=UTF8 to mysql maybe. |