Export and import a TXP database
This tutorial covers the exporting and importing of your Textpattern database. In this example we export a current database which will be used to develop a new revision of the site locally, using MAMP on OSX.
The example may also be useful for developers looking to avoid constant installations of favourite plugins when developing new sites. You can create a base installation of TXP and use this method to import the database into your new project.
Export your database with phpMyAdmin
We will use phpMyAdmin to export the database. Once you have selected your database, choose export from the top menu. In the export tab, choose select all to select all the database tables for export.
You should not need to change any other settings, although some hosts have different options enabled. On my host, I have to check save as file. Choose your compression type – gzipped is fine.
Click Go and you should have a backup of your database either on your desktop or in your downloads folder.
Download and install MAMP
In case you have not yet installed MAMP, download and install it into your Applications folder. After a successful install, MAMP will open itself in Safari.
Create a new site in your MAMP install
Creating new sites for local development is easy with MAMP. Visit Applications > MAMP > htdocs and create a new folder there. Let’s call it txp_dev.
Install Textpattern in your new site
Either install a clean copy of Textpattern or download your current site into the txp_dev folder. I chose to download my current site, because I want to revise the layout and design locally.
Import the database
Go back to MAMP and click on the phpMyAdmin link. Create a new database, let’s call it txp_dev_db. In the new database, choose import. Choose the SQL file you exported earlier, and click go.
If all goes well, you should see a success message.
Edit your Textpattern config.php file
Visit your Textpattern install in Applications > MAMP > htdocs > txp_dev. If you downloaded your current TXP install, you will need to edit config.php to reflect any new settings.
Edit your Textpattern paths
Visit your TXP Admin. Navigate to Admin > Preferences. Change the URL to your local MAMP URL –
The choose Advanced Preferences and change the File directory path to
Then change Temporary directory path to
That should be about it. You may need to change some file permissions, so check in Admin > Diagnostics for any error messages.