Restoring MySQL Databases

May 21st, 2008 By: brian

This is a quick post to possibly save someone some time when they google for restoring mysql data files. The gist of it is, don’t try to copy InnoDB files directly into your data directory, it won’t work.

Background

Sometime back I wiped my development box clean and reinstalled the OS from scratch. It’s a wonderful feeling to start fresh and get rid of all the old whacky configs and random junk that collects on a filesystem. Prior to this cleansing, I backed up all the junk I considered save-worthy. One thing I saved was they MySQL data directory. Many of the databases were old projects and at the time I didn’t think I’d need to look at them anytime soon. Well, anytime soon arrived yesterday in the form of me really wanting to see how I had implemented a particular feature in an old project. The database component of that project was essential, so I couldn’t just glance at the code, I wanted to get it running again with the database backend.

Problem

I probably should have known better, but I decided to just try to shutdown mysql and copy the files directly to my new data directory. After some permission and user adjusting, that seemed to work… until I actually tried to access the restored database I needed, which used mostly InnoDB tables. They were not showing up or working properly. A quick glance revealed a file I hadn’t copied which seemed like it *might* be something important:

$ ls -lh /Backup/mysql/data/
-rw-rw----    1 brian  staff   1.0G May 21 10:05 ibdata1

Yeah, oops. So InnoDB stores things a bit differently than MyISAM.

Solution

The solution turns out to be simple and is what I should have done in the first place.

First, shutdown the mysql server:

$ mysqladmin -u root -p shutdown

Next, startup mysqld with the –datadir option pointing to your old data directory:

$ mysqld --datadir=/Backup/mysql/data/

It may complain about some issue with writing to log files, but that doesn’t matter for this quick export.

Now just dump your database as you normally would (or should have originally):

$ mysqldump -u root -p database_name > database_name.sql

Lastly, shutdown mysqld again, start mysqld normally and then do the import as usual:

$ mysql -u root -p database_name < database_name.sql

(you’ll likely need to create the database first)

There you have it - the way to get your old database files restored into your current setup. There is probably some better easier way to do this, and if someone knows it, clue me in will ya?


Setting up Slony on Windows

May 13th, 2008 By: james

This isn’t intended to be a complete tutorial, but for those of us who have previously only run Slony on Linux, this might be a helpful post.
Read the rest of this entry »


Flash AS3 Loading Fonts

May 13th, 2008 By: dan

Create a Flash AS3 application that loads an external font at runtime… Sounds easy enough… But it is a little tricky. I needed to create a flash app that allowed users to choose a font from a list and load that into a player. I wanted to offer several fonts but did not want to bloat the load-time with unused fonts. I could not find much help on this topic… Luckily I found betriebsraum and with that I was able to hack up something that worked for me.
Read the rest of this entry »


How Can I Improve My Site’s Ranking?

April 22nd, 2008 By: andrew

This question has entered the minds of website owners hundreds of times. Being on the first page of results within a search engine can mean the difference between success and failure.

In response to the question “How can I improve my site’s ranking?” Google has given the answer. “In general, webmasters can improve the rank of their sites by increasing the number of high-quality sites that link to their pages.”

Hundreds of factors go into determining a sites rank within a search engine, however, possibly the most important is the number of high-quality inbound links to your website. By high-quality we mean sites that themselves rank high in search engines, and are relevant and similar to your websites content.

A simple search on “Link Submission” on Google will turn up thousands of websites that will accept, and dispay a link to your site on their site. You could go about submitting to hundreds of these sites, but it will likely not increase you position within any search engine. These submissions can actually hurt your site’s ranking, not improve it.

So who should I submit my link to?

While trying to avoid submitting your link to a hundred places, there are a few key places that you should submit to. You will want to add your site to the Google Index. Yahoo also provides a free site submission into their index here. You may want to consider adding your site to DMOZ.org. DMOZ is a web directory which is human edited. Getting your site listed here will also get your site listed in the Google Directory (Google uses DMOZ.org’s directory). You can submit your site to DMOZ here.

Great. Now What?

After you have submitted your site to the major search engines, you’ll want to trade links with websites that are well placed within your industry. Do a google search on a few keywords that pertain to your website. Lets say “poodle puppies.” Get the list of the top 15-20 websites that currently appear on Google or Yahoo under that keyword. Next, write an individual email to each of them asking to trade links with them. You may even consider buying a link on their site.

As soon as they add the links and the search engines become aware that they link to your site, your site’s ranking will dramatically increase.

The key to success here is not to give up. You should be continually trying to get high quality links to your site as you grow. My Next article will deal with internally improving your website to increase your ranking on Search Engines. We’ll talk about layout, structure, meta tags, alt tags and title tags that will affect your site’s ranking.

Stay Tuned!