August 15, 2004

MySQL or Berkeley DB?

When installing Movable Type for the first time, you have a choice of what database to use - MySQL, PostgreSQL, SQLite, or the default - Berkeley DB. The recommended choice is MySQL for many reasons. MySQL is more stable, more powerful, more easily editable than Berkeley DB. With one simple command you can back-up your entire MySQL database (See Backing Up Your Blog). Many web hosts offer a cPanel or phpMyAdmin utility to manage your database, making it easy to make global changes to your weblog.

If you are using Berkeley DB and you change servers, or your host upgrades your server (this has happened to me twice in the last year), the version of Berkeley DB must be exactly the same on the new server than was on the old or your database won't work and you will not be able to access the MT edit window.

The default database that comes with Movable Type 3.15 and earlier versions is Berkeley DB. Many people end up using Berkeley because, even though they have access to a MySQL database, the installation instructions for BDB are just a little less confusing than for MySQL. This is a mistake. If your web host offers MySQL, by all means use it. If your web host doesn't offer MySQL, you should change web hosts and find one that does. Trying to trouble-shoot MT when the Berkeley DB has become corrupted is simply not worth the pain. From what I understand, in the future the default database for MT will be some version of SQL, not BerkeleyDB.

Upgrading from Berkeley DB to MySQL

If you are already using Berkeley DB on an MT installation, you can switch your database to MySQL by following the instructions posted on the MT Manual for Converting your Berkeley DB database to a SQL database. You will need access to an upgrade script file named mt-db2sql.cgi which you can find in an upgrade version of Movable Type. For example, if you have downloaded and installed the full version of MT2.661, you will need to download the upgrade version of MT2.661 to find the above script. Make sure you use the script associated with the version of MT that you are running.

Installing MT with MySQL

The Configuration section of the MT Install Guide lays out the steps for setting up your MySQL database. The instructions are a little obtuse, so I'll try to simplify.

1. Confirm that your host supports MySQL.

2. Find out from your host the following information:
---a. The name of the MySQL database
---b. The user name connected to the database
---c. The password for the database

3. Add the following lines to your mt.cfg file using a text editor like BBEdit:

ObjectDriver DBI::mysql
Database database_name
DBUser database_user

Substitute "database_name" with the name of your database.
Substitute "database_user" with the user name for your database.

Here's an example of what this could look like:


Note the additions to these lines if your MySQL database server is on a different host, in a non-standard location, or is on a different port than the default. Your webhost should be able to help you determine the host name, path, and/or port number in this case.

4. Set your password for the MySQL database in the mt-db-pass.cgi file.

Open mt-db-pass.cgi in a text editor. Change the line "database_password" to the password of your database. Save the file.

How many entries can a MySQL database hold? - imabug on this MT Support Forum thread has the answer.

Please direct ALL questions regarding installation of Movable Type or your particular database troubleshooting to the MT Support Forums. There is an entire section of the forums devoted to database issues. I will leave comments open here for those who want to add to, correct, or clarify something in this tutorial. Other comments may get deleted.

Has this tutorial been helpful? Please consider linking to Learning Movable Type at . Thanks!

Posted by Elise Bauer on August 15, 2004 to Beginner Tips, Install
Comments(2) | Email to a friend | Printer-friendly version


If you would like to send a trackback
please use the following URL:


You wrote, "When installing Movable Type for the first time, you have a choice of what database to use - MySQL or Berkeley DB."

I just installed MT yesterday for the first time, and it seemed that not choosing either database was also an option, because I don't recall choosing either. Your statement made it seem like you HAD to choose one or the other.

I am confused about what I can't do without MySql or Berkeley DB. I write here only in the case that my newbie feedback might actually be valuable to you, and realize you are not a support person (=

That said, I really appreciate your site!!! It's so pretty and useful. I will surely link to you as soon as I re-establish my blog after moving from hosts & from Blogger.

Hi Michael - if you look at your mt.cfg file you can see what database you are using. If Datasource ./db doesn't have a # before it, and does have a path listed after the word Datasource, then you are using Berkeley DB. The choice for databases is made in the configuration section of the install guide. There are two main reasons for using MySQL over Berkeley DB. Berkeley DB is not as stable. It can, and does on occassion as many can attest, get corrupted. When this happens, unless you have been diligent in backing up your weblog, you can lose your data, all of your entries.

The second reason is that MySQL is more powerful. There are customizations you can make to MT that only work if you are using a MySQL database. Doing a search for MySQL in the forums may turn up some examples. It is also very easy to back up data when you have MySQL. When my server was flaking out the other day and my web host transfered my files to a different server, my MT installation was up and running in no time - a simple change to the database password file. When this happened when I was using Berkeley DB, it took me an entire week of troubleshooting and reinstalling to get MT working again. This is a common occurence noted in the support forums.

Comments are now closed for this entry.

Email to a friend

Email this article to:

Your email address:

Message (optional):