How to Install a MySQL Database using a MySQL Injection Script


by Miss ec - Date: 2007-01-22 - Word Count: 688 Share This!

Whenever you purchase or acquire a MySQL database (such as from a website like WebContents.org), chances are it will come as a MySQL injection script. An injection script is simply a SQL script that, when executed, creates the appropriate database tables and inserts the data using INSERT statements (one statement per record of data). Because of this, a SQL injection script is usually very large, but this is the easiest way to export and import a database so this is how it is usually done.

Once you have the injection script, installing it is usually very easy. Of course, you must already have MySQL Server (mysql.org) installed on your server, so if you haven't done that yet (such as if this is a new server), do it first, then put the script file in an easily accessible location (like the root folder of the server's main hard drive, usually drive C, or in the temp folder).

The process for installing a MySQL database using a MySQL injection script is fairly trivial, but there are a couple of snags you might run into along the way. The only way to find out if these apply to you, however, is to attempt to install the database using the script normally, and deal with exceptions as they occur. To execute the injection script, you first need to create a database to hold the data. Open a command prompt and type in the following command to start the MySQL command-line interface: "mysql -u root -p" (without the quotes). It will prompt you for the root password, then you will be logged into the MySQL instance.

To create the database, use the command "create database imported;" (without the quotes). Substitute the word imported for whatever database name you would like to use, and make sure you put in the semicolon at the end. If successful it should say "Query OK, 1 row affected". Now you are ready to run the injection script itself.

To execute the injection script, use the command "source c:tempvegrecipes.sql;" (without the quotes). Use whatever path and filename points to your injection script, and don't forget the semicolon at the end! It may take a while to run depending on how large the script is, but it should say "Query OK, 1 row affected" for each record that it inserts into the database.

That's it! The database should be installed, and you can find the data in whatever table is named at the beginning of the MySQL injection script (open it in notepad to see). The two most likely problems you might run into are unicode translation and script size. Depending on where you got the script, it may be formatted for a different Unicode set than your system normally uses -- if the script won't execute at all, open the script up in notepad and look for strange characters at the beginning of the file (delete them if you find any), then re-run the script. The other problem that might occur is if the injection script is VERY large -- your system may run out of memory or hang while it is trying to load/run the script. In this case, you might want to split the injection script into multiple files that can be executed in sequence. If you need to do this, you can use any program that will split a file BY LINE (not by characters or bytes because you don't want half a command to be in one file and the other half in the next), but a good one to use is SplitFile from rethinkit.com.

Now that you have the capability to install externally obtained MySQL databases using MySQL injection scripts, you may find that it is much easier to acquire databases this way rather than building them yourself from scratch. A good place to get MySQL injection script databases is www.WebContents.org. This is a great way to add large amounts of fresh content to your website, or even content that is not necessary but could be a nice additional feature for your website such as a joke or quote of the day, or food recipes, or rss feeds... the possibilites are endless!




Related Tags: content, webmaster, server, resources, script, database, install, mysql, setup, injection, acquire, execute

Your Article Search Directory : Find in Articles

© The article above is copyrighted by it's author. You're allowed to distribute this work according to the Creative Commons Attribution-NoDerivs license.
 

Recent articles in this category:



Most viewed articles in this category: