Database Conversion
Question
How do I convert from one database type to another?
Answer
Convert from Berkeley to SQL
To determine whether your server supports a SQL database, and the Perl libraries required to connect to it, run mt-check.cgi and look at the status for any of the following modules: DBD::mysql, DBD::Pg, or DBD::SQLite. If any of these are installed, your server will support that version of Movable Type. If none of these are installed, you will need to contact your host to have them installed if you wish to use a SQL database.
If you are interested in converting your data, a conversion script to copy your data from the Berkeley DB files into the SQL database is included in the upgrade distribution (mt-db2sql.cgi, a Perl script that will create the necessary schema in your SQL database, then populate the database with the data from your Berkeley DB files). To convert your existing installation to using a SQL database, follow these steps:
Edit Configuration File
Open mt-config.cgi1 in a plain text editor, and add these lines to it:
ObjectDriver driver_name
Database database_name
DBUser database_user
DBPassword database_password
where:
driver_nameis one of the following:DBI::mysql,DBI::postgres, orDBI::sqlite;database_nameis the name of the SQL database where you wish to store your data;-
database_useris the username used to connect to that database -
database_passwordis the password assigned to the database_user2
(Note that if you are using SQLite, neither a username nor a password is required).
If your SQL database server is on a different host, you can use DBHost to specify the hostname:
DBHost database_host
Important: if you are using either PostgreSQL or MySQL, the database that you specify in database_name must already exist3; Movable Type cannot create it automatically!
Run Conversion Script
Make sure that mt-db2sql.cgi is on your server in your Movable Type installation directory. This file is included with the Movable Type distribution. (As of version 3.11, this script is included in both the full and upgrade distributions; in versions prior to that, the file was only included with the upgrade package. If you do not have this file, you may need to first upgrade to the latest version of Movable Type.)
After uploading mt-db2sql.cgi to your server and setting permissions to 755, open your web browser and point it at the URL for mt-db2sql.cgi on your site.
For example, if your site is http://www.example.com/, and you uploaded the Movable Type files into the /mt directory, you'd type http://www.example.com/mt/mt-db2sql.cgi.
Check For Success
Once mt-db2sql.cgi has finished executing, look at the bottom of the page in your browser to check whether the conversion was successful. If it was, this message will be displayed:
Done copying data from Berkeley DB to SQL database! All went well.
If you received this message, you're done. When you log in to Movable Type and use the system, you will now be using the SQL version of the system.
If there was a problem with the conversion, you should see:
An error occurred while loading data:
displayed, along with the actual error message. If you do see an error, edit mt-config.cgi and comment4 the SQL settings you added before.
Now you will be back to using the Berkeley DB version of Movable Type. Consult the Knowledge Base for more information on the error; open a new help ticket from Your Account to receive assistance if your error is not listed, or try searching/posting on the Community Forum.
Convert from one SQL to another SQL
There is currently no direct path or conversion script for this. We recommend that you export your weblog while Movable Type is configured for the one database, then reinstall Movable Type for the new database just as you would for a fresh installation. Finally, import the weblog content into the new installation.
Convert from SQL to Berkeley
There is currently no conversion script for this - we strongly advise staying with SQL as opposed to Berkeley.
1 In versions prior to 3.2, the configuration file is named mt.cfg.
2 In versions prior to 3.2, the password is set separately in mt-db-pass.cgi. After opening this file in a plain text editor, replace database_password with the password used to connect to your SQL database.
3 If your host offers you CPanel, you can probably create the MySQL database yourself. See Create MySQL Database Using CPanel. Otherwise, contact your host for information on how to create a database on your account.
4 To comment a setting means to add a # to the beginning of the line where it appears.


