Archive for category mysql

My Initial MySQL db is Broken, Help!

Typically a backup or dump of a MySQL server includes all of the databases available, using the -A or –all-databases options. But what of restoring, and recovering that dump?

One can simply go to the target machine, and delete everything in the data directory, right? Oops, you didn’t delete the initial MySQL database did you? How about the special “information_schema”, MySQL’s data dictionary? The other option of course is to use mysqladmin:

SQL> mysqladmin -f -u root -p drop mydatabase

But still I’ve had cases where I’ve dropped parts or all of these initial MySQL databases. So what to do if you do?

Luckily MySQL comes with a shell script to save you in just such cases. It’s called mysql_install_db and can typically be found in /usr/bin. For Oracle folks you can almost think of this like the catalog.sql which in turn runs the sql.bsq file. It is illustrative to take a look at this shell script, and see what’s contained in there. You’ll learn a lot about the bootstrapping process.

MySQL has documentation on the mysql_install_db script.

So when you go to building your backup scripts, and are putting all the pieces in place, be sure to make a note of this script, and remember where it is. If you are providing instructions for recovery for Unix Admins who may not know MySQL particularly well, be sure there is a note, or even better yet, a call to this script in your own restore scripts.

DBJ: Oracle, MySQL + Postgres Compared Part II

In Part II in this series, I talk about how these three databases compare in some particularly crucial areas.

For instance how do the optimizers of these different database engines behave, and why does that matter?  What type of indexes are available, particularly with respect to typical applications.  I then move on to datatypes available and which are missing.  You’ll find some surprises here.

Lastly the holy grail of any modern relational database, I discuss transactional support. Relevant concepts include ACID compliance, read-only versus insert and update activity, and so on.

MySQL Replication in a Box

Recently I wanted to setup a little MySQL sandbox where I could hack away at MySQL with reckless abandon.? A sandbox is different than a test environment, it’s usually one which is very breakable.? You want to be able to break things, or rather take them completely apart and put them back together.? It’s the only way to understand all of the moving parts.

So searching google, I happened upon Giuseppe Maxia’s Replication Playground. It basically installs into an unprivileged directory, one master, and three slaves.? You can then test out various scenarios. Read his blog entry.

It is trivial to install, however I encountered some issues with MySQL 5.0, which caused me some troubles.? I sent him my feedback, and comments, and it looks like he has rereleased it as the MySQL Sandbox. Good stuff.

DBJ: Oracle, MySQL, Postgres Compared

If you’re interested in how these three databases measure up in terms of feature sets, take a look at part one in a two part series I wrote over at Database Journal.

I discuss stored procedures, views, materialized views or snapshots, triggers, and security. Stored procedures and functions are supported on all three databases, as are views and triggers. Although MySQL and Postgres aren’t there in terms of default snapshot support, there are ways to get that functionality in a somewhat roundabout way.

Security is always a tricky question, as all the bugs out there aren’t always publicized. It’s sort of a cat and mouse game. All three databases support user based authentication to login to the database, and various privilege levels to control access to objects and data. Oracle also supports FGA or fine grained access control for column level control.

That said I might tend to say that open-source products in general have better security, their source being an open book and all.