Solved

How to convert a mysql database to utf-8

Posted on 2010-11-10
5
620 Views
Last Modified: 2013-12-12
I have a dump file of my Moodle 1.8 instance. The instance was on a server that is now physically dead. I am trying to move it to a Moodle 1.9 server, but when I attempt to upgrade, I get a message stating that all my tables have to be in UTF-8 before proceeding. How can I convert the entire dump file to UTF-8?
0
Comment
Question by:smetterd
5 Comments
 
LVL 13

Expert Comment

by:dsmile
ID: 34101979
If you mean you have to convert that dump file to UTF-8 encoding to use with Moodle upgrading process, then it means you need to convert a text file to UTF-8 encoding. If that's really the case, then use some UTF-8 supporting text editor like EmEditor or Edit Plus (both are available in trial version) to open that dump file and save it as UTF-8 encoding.

If your case is that you import that dump file to a new DB, but it isn't UTF-8 encoding yet, then you can import again with this command

mysql -h host -u username -p password --default_character_set utf8 database < your_dump_file
0
 
LVL 6

Expert Comment

by:Ferrosti
ID: 34102222
The most comfortable way would be to setup mySQL with UTF-8 as global default and restore your dump then. Make sure first that there are no commands in your dump file to create your tables in another codepage.
0
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 500 total points
ID: 34105984
Use this

ALTER TABLE table1
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci;

Change last row accordingly your needs

Cheers
0
 
LVL 2

Author Comment

by:smetterd
ID: 34113722
Is this allowable?

ALTER DATABASE database1
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci;
0
 
LVL 2

Author Closing Comment

by:smetterd
ID: 34113945
ALTER DATABASE harlinge_drcmdl
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci;


Worked perfectly! Thank you!
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now