Introduction | Creating the remote database | Creating the local database
OK, so now what?| Deciding on fields | Deciding on an index | Creating the table | Insert some data
Querying the database| Scripted querying | Uploading onto the server

Getting the database onto the server

We now have a database on our local server, but how do we manage to put this database on the remote server so that the MySQL server (and our web page) can access it? Well, the first step is to extract the database into a form which we can manage without much effort, this basically involves putting the entire database into a file so we can simply upload the file onto the server and import it into the database. Thankfully somebody else already thought about this and decided to lend a helping hand by creating a program to do exactly this, it is called "mysqldump", which is used for extracting a table(s) from a database and saving the contents to a file. The syntax is very simple, I used;

	$> mysqldump -u <username> -p <databasename> --opt -c -e > <databasename>.dump

It will create a file called "<databasename>.dump" which will contain the entire contents of the database in a human-readable form, this is also usable by the MySQL client "mysql" to import the data into the database. You may notice that the file created is simply a stream of SQL statements, this is so that the MySQL client can simply interprete them as a user may have typed them in, the client knows no difference. This was we can use the MySQL client to enter the data back into the database at the remote server. This is only possible of course if a shell (telnet or SSH) is accessible, otherwise a different method must be used, one such method is by using "Matt's MySQL Control Panel", available here, it is a free (licensed under the GPL) MySQL administration program written for use via a web interface which can be used to import data into a database. The other possiblity for importing data into a database is, as I have already mentioned, to use the MySQL client and a telnet/SSH session. The file containing the database information maybe quite large as lots of data may have been stored in your database, if this is the case I would suggest using a compression program to compress the file to make it smaller and quicker to upload onto the server, a program such as WinZIP would suffice quite well, as there are many programs available for Linux which should be available to decompress at the remote server. After compression a file with the extension ZIP should have been created, the exact filename was up to you at the point of compression, but from here on it will be called "<databasename>.dump.zip". This file now needs uploading onto the remote server, in order to do this you will need FTP access (or similar file system access such as NFS, SMB etc). Once connected you need to upload the compressed file to a place where you have read/write access (perhaps your home directory?). At this point you need to have access to a shell where you can invoke the MySQL client, the most popular methods are either telnet or SSH, either will work fine (as will any viable alternative) providing they allow you access to the previously uploaded file and the MySQL client program "mysql". Change the current directory to the same directory as where you uploaded the compressed database file and decompress the data file (using the appropriate decompression program, if ZIP compression was used then "unzip" program should perform this for you) then run the following command to invoke the MySQL client to enter the data into the database (assuming that the database has been created on the remote server).

	$> mysql -u <username> -p <databasename> < <databasename>.dump

If any errors occur then check that you have done everything correctly, otherwise congratulations your database is now on the server and ready to be accessed by your web page! Good luck.


Introduction | Creating the remote database | Creating the local database
OK, so now what?| Deciding on fields | Deciding on an index | Creating the table | Insert some data
Querying the database| Scripted querying | Uploading onto the server