Transferring database to host server

If you initially tested your pages on your local computer and are now ready to transfer to your webhost, these are the instructions to follow. I will admit that I had difficulties connecting to my host and ended up needing to change to another host. I was actually happy with my host, but with all the programs and databases necessary for Drupal, it was very confusing for me. However, if you have a good host, the process is much easier. The host I switched to, Hotdrupal, was a very easy host to work with and I suggest you use them.

Set up database on host server

If you have been following the tutorials on this site, you probably already know this by now, but it is important to repeat that in order for drupal to work you must be connecting to your host server’s database, NOT the database on your own computer. This might be intuitive to most people but for those who do not know the process, it can be very difficult to figure out. Anyhow, once you have both databases set up, you will export the database information from your local computer, and then import it into your webhost database.

*Before moving on, make sure your host grants you access to at least one database. If you don’t know if you have access to a database, ask your host, because you need to have a database in order for Drupal to work. If your host does not have a database in which you can access, you have no choice but to GET A NEW HOST!*

At this point, you should have already created a database on your own computer. Now, you will set up a database on your host’s server. The process to do that will be different for each host. Hotdrupal happens to use MySQL and PhpMyAdmin for the databases on their server and it was easy to set up. Some hosts, like my original host, create their own database system or use something else, which can complicate things a bit. Remember that MySQL is a database and phpMyAdmin is just an interface that makes it easier to use MySQL. I think the complications arise when your host uses a different database because phpMyAdmin was created to work with MySQL and therefore does not work as well with different database. If your host is using a database other than MySQL and does not have phpMyAdmin set up, you may need to create a separate phpMyAdmin account. I suggest before moving forward that you ask your host how they suggest you connect to their database. If you need to create a separate phpMyAdmin account, you can follow the below instructions, but you are probably better off talking to your host. Since each host is different, your process might be slightly different than the process used in the below instructions, but they should be pretty close. If you have any difficulties with these instructions, please contact me through the Contact page and hopefully I can help you myself. If you already have a phpMyAdmin account or something similar, you can skip to the Export database section of this article.

Set up a separate phpMyAdmin account

Go to http://www.phpMyAdmin.net and download phpMyAdmin. For instructions on how to do so, visit the Installing phpMyAdmin article. You can save the download file wherever you want, and then extract it to your root folder (in my case C:\htdocs). Next, you will need to configure phpMyAdmin with your specific settings. To do this, create a config.inc.php file yourself, which allows for some more advanced features and is the approach I took.

Create a folder in your host’s server

To configure phpMyAdmin, you first need to create a new folder in your host’s server. Your host should provide instructions on how to do so (oftentimes they call it “adding a directory”), or you can ask them. With the host I used, FutureQuest, I created a folder named pma, which is where I eventually transferred my database.

Create config.inc.php file

Now, you will need to create a file named config.inc.php directly within the phpMyAdmin folder you just extracted on your computer (in my case it is at C:\htdocs\phpMyAdmin-3.1.2-all-languages). There should be a config.sample.inc.php file in there and, if you wish, you can create a copy of it and name it config.inc.php to use it as a template. Otherwise, just create a blank text file named config.inc.php.

If you decided to use the config.sample.inc.php file as a template, it should look something like the following (if you have a blank text file you can just copy and past this):

<?php

$i=0;

$i++;

$cfg['PmaAbsoluteUri'] = ‘http://example.com/pma/’;

$cfg['Servers'][$i]['host'] = ‘MySQL.example.com’;

$cfg['Servers'][$i]['auth_type'] = ‘cookie’;

$cfg['blowfish_secret'] = ‘Suzy did 100 jumping jacks Tuesday morning!’;

$cfg['Servers'][$i]['user'] = ”;

$cfg['Servers'][$i]['password'] = ”;

?>

You now need to make the following changes to the following lines in order for it to work with your host:

$cfg['PmaAbsoluteUri'] = ‘http://example.com/pma/directory’; — replace example.com with your domain name and directory with the name of the phpMyAdmin folder you created in your htdocs folder (in my case phpMyAdmin-3.1.2-all-languages). In my case the final result looks like the following: ‘http://buildyourownstory.com/pma/phpMyAdmin-3.1.2-all-languages.

$cfg['Servers'][$i]['host'] = ‘MySQL.example.com’; — replace example.com with your domain name

$cfg['Servers'][$i]['auth_type'] = ”; — dictates the authentication method used when connecting to your phpMyAdmin installation – see below

You can use any of the following options:

cookie (recommended method)

http

config

signon

The cookie and http methods are considered the most secure. Since we chose the cookie method, we do not need to change anything.

$cfg['blowfish_secret'] = ”; — this is only used with the cookie method. Here is where you will enter a random phrase of up to 46 characters long. It is used just to encrypt the password. You can just leave the phrase as-is, and you will not need to enter it later.

$cfg['Servers'][$i]['user'] = ”; — Enter the username for your database on the host’s server.

$cfg['Servers'][$i]['password'] = ”; — Enter the password for your database on the host’s server.

Make sure you don’t have any blank lines at the end of the file and save it as config.inc.php.

Now, open your web browser and visit

http://example.com/phpmyadmin/index.php (replace example.com with your domain name). You should be taken to the phpMyAdmin welcome page and you can now access the databases on your host’s server. Whew!

Export database

Now that you have separate phpMyAdmin accounts on your computer, as well as on your host’s server, we will take the Drupal database you setup on your computer and export it to the database on your host’s server.

First, go to the phpMyAdmin account set up on your own computer (by typing what into the browser?). On the left hand side of the screen, click on your Drupal database name (in my case buildyourownstory). Click the Export tab at the top of the screen. You can leave most settings unchanged aside from the following:

In the “Data” section, uncheck “Complete inserts” and “Extended inserts.” In the Export section, make sure the SQL button is selected. At the bottom, check the File box. THIS IS VERY IMPORTANT, because otherwise nothing will happen. In the “File name template box, enter what you want to name the file. I chose buildyourownstory_backup_02_23_09. Click Go and save the file wherever you want. I chose my desktop.

Next, open the phpMyAdmin account you set up on your host’s server by going to http://example.com/phpmyadmin/index.php. Like in the previous step, on the left hand side of the screen, click on your Drupal database name. Click the Import tab at the top of the screen. Click the Browse button, and browse for the file you just created. Now, all of the data from your Drupal database on your local computer has been copied into your host’s database.

Download ftp software

Now, you need to transfer all of your Drupal files over to your host. Some hosts have programs set up to do this, but I suggest that you download ftp (file transfer protocol) software yourself. The software is free and easy to set up. I chose to use a program named FileZilla and you can find the instructions on how to install it in the “FileZilla Instructions” section.

Transfer the files

At this point, you should have a domain name and a webhost, downloaded Drupal and an ftp program, and set up a database. Now you are ready to transfer the files, also known as uploading the files. The following instructions are how to transfer files using FileZilla, but it should be a very similar process with any other ftp programs. Follow these instructions carefully. It is a pretty easy process and not a total disaster if you don’t do it correctly, but believe me you want to get it right the first time.

Open FileZilla if you have not done so already. Now you need to connect to your host. If you have not entered your host information yet, see the Plug in host information section of FileZilla Instructions. Go to the File menu and select “Site Manager…” In the menu that appears, click “Connect.” If all goes well, in the large text area beneath the Host, Username, Password, and Port fields, the final line of words should say something like “Status: Directory listing successful.”

If you don’t see something like that, it most likely means that some of the information you entered was incorrect. If you confirm that you entered the correct information, try changing the Port number to 22, 21, or leaving it blank. If that still doesn’t work, you can ask your webhost to provide you with the IP address of your webhost. If your host asks you to provide the IP address of your personal computer, you can find it by going to http://whatsmyip.org/.

In the middle section of the screen you will notice that it is split into two sections. The left side of the screen displays the contents of your local computer and the right side displays the contents of your host server account. Each side is also split into a top and bottom section. Both sections display the same contents in different ways and are set up very similarly to the way your computer displays files. In the bottom section, you will notice the top folder is labeled “..” Clicking on this folder will bring you up a level.

There are a couple of ways you can transfer/upload files. You can click the server folder in which you want to transfer the files and right click on the folder/file from your computer and select Upload, or you can simply drag the folder from the left side over to the folder you choose on the right side. Either way is fine.

Now you are ready to transfer your Drupal files. In the host server section on the right side, select the folder at the highest level. You will probably want to ask your host which folder they use for files that the public can view. This is normally a folder named “public_html” or “www,” or in my case both of the folders are exactly the same. In your local computer section on the left side, find your drupal folder (in my case it is in the C:\htdocs\ folder) but DO NOT TRANSFER/UPLOAD IT. If you transfer the entire drupal folder, your site will end up having “/drupal” at the end of it, and instead of entering buildyourownstory.com, people would need to enter buildyourownstory.com/drupal. What you need to do is transfer all of the folders and files separately. First, click the little plus sign next to the drupal folder to open its contents. Then, click on the first folder within the drupal folder (probably titled “includes”) and transfer/upload it to the appropriate folder from your host server mentioned above. When you do this, the tabs at the bottom will indicate how many files you are transferring and the section above will show the files being transferred. Then, do the same with every other folder within the drupal folder. Now, make sure you also transfer the files within the drupal folder. This is an easy step to skip if you aren’t careful (as I was the first time I tried). To do that, in the top section click on the drupal folder you just opened. It doesn’t matter if it has the plus sign or the minus sign next to it. Just make sure that drupal is highlighted. Then, in the bottom section, scroll down to the end of the list of folders and then click on the first individual file you see (probably .htaccess). We can actually transfer all of the files together, which you can do by holding down the Shift key, scroll down to the very bottom, then click the last file, which will highlight all of the files. Then transfer all of the files just as you did before. Make doubly sure that you transfer the .htaccess file because it is a necessary file.

The next step is to go to the Drupal installation page.

Now, you need to change the user info in the settings.php file in your drupal folder on your computer.

Before we continue, now might be a good time for you to get acquainted with Drupal a little bit, so I suggest that you check out the Getting Started article on Drupal’s site. You can find it by navigating to the Drupal homepage at http://drupal.org/ and clicking on the About Drupal link and in the Quick Links section on the left side of the screen and then the Getting Started link or click the following link: http://drupal.org/getting-started. Drupal also has an installation guide at http://drupal.org/getting-started/install, but I suggest that you follow my instructions, because their instructions confused the heck out of me and I had no idea why I was doing what I was doing.

The best option is to simply create the database on your host’s server and connect directly with Drupal, but I couldn’t get it to work. My host (FutureQuest) provides the following instructions that might also be useful for you for setting up a database with your own host if you want to try. This didn’t work for me, so here are my instructions on how to set up a database on your own computer, create a database with your host, then export your database information from your computer’s database to your host server’s database.

Create pma folder

To configure phpMyAdmin, you first need to create a new folder named pma in your host’s server. Your host should provide instructions on how to do so (oftentimes they call it “adding a directory”), or you can ask them. This will create a path that looks something similar to /big/dom/yourdatabasename/www/pma. This is where you will eventually transfer your database.

Posted on January 22, 2010 at 2:42 am by Scott Butler · Permalink
In: Getting Started

Leave a Reply