Friday, September 9, 2011

How To Create, Import & Export MySQL Databases via cPanel

  A MySQL database is a way of organizing information tables with a common theme. Items such as address and phone lists, bits of information, email addresses, inventories, price lists, etc., all represent information that can be stored and accessed through a database. A static website will typically suffice if the information is not extensive. However, for large amounts of information displayed in numerous places, a database makes the information easier to update and manage. Making effective use of a MySQL Database consists of being able to create, import and export the information through your cPanel.
 
Creating A Database
The first step is to create the database in question. A database typically contains many tables that can all be linked together. If the tables are linked, the database is said to be a "relational" database. If your database has just one table, it is considered to be a "flat-file" database. To create a database you should log into cPanel and access the MySQL databases tab. Next, type the name you have chosen for your new database in the "Create New Database" field and choose "Create." This saves the database under that given name.

It is possible allow users to access your database simply by configuring the database settings regardless of the type of database you create. Users are assigned access by your logging into cPanel and accessing the MySQL databases tab. Next, assign a user and choose "ALL" privileges and rights to the database. This grants the user access to the information the database has stored.

Using phpMyAdmin

As a part of the cPanel interface, phpMyAdmin is used to manage MySQL databases. To access this feature, your database must already exist within the cPanel. Open the phpMyAdmin tab in cPanel and a box will open allowing you to select the database you wish to manage. You will then be able to choose a table icon that lets you edit individual tables within the database. Next, choose the table icon to open and edit that table. The command "X" removes a specific row within the table and the "pencil" icon lets you change values and edit the contents of a specific row. Once the changes are completed to your satisfaction, choose "Go" or "Save."

Third Party Software and Settings For Your Database

When third party software is going to be accessing your database, there are some settings that are required for the config files. They most frequently are:

1.  Hostname - "Localhost" is typically used for the hostname and shows that the third party software is accessing the database "locally", or to another database hosted on the same computer.

2.  Username & Database Name - This name consists of a combination of the hosting username and the database name. For example, with a hosting username of "misc01," a database named "discussion" and a user named "mod," username would be "misc01_discussion," with the username being "misc01_mod."

3.  Password - Set for whichever database user is accessing the system.

Allowing Access Hosts

There are times when it may become necessary to connect to your database via remote. It is simple to assign access hosts to enable connection with software already on your computer or from another website. To do this you will need to assign permission to that host in order for the database to be accessed. This is easily done using the Remote MySQL option in your cPanel.

When creating access rules, it is always wise to be as detailed as possible. You should make sure your rules are styled so that they are broad enough to give the access you wish, without being so broad that they allow more access than is desired. When creating rules for database access, you can choose either IP addresses, hostnames or wildcards. For wildcards, a percent sign (%) is used.

For example:

192% - allows all IP’s beginning with 192
% - allows all IP’s and hostnames

Importing a Database

Importing a database is simple using phpMyAdmin or the administrative panel within your software depending on the software in use. Uploading a database file can be done through the “Import” or the “SQL” link. Both options will automatically populate the database information on upload. One important thing to remember when importing databases using phpMyAdmin is that tables cannot be overwritten, so the tables must be new. Also, due to PHP software limitations, databases cannot be over 50mb. For databases over this size, it is recommended to backup the database and import them manually using technical support provided by your hosting company.

Exporting A Database Using phpMyAdmin

Exporting a database is best described as downloading specific tables into a predetermined SQL File. PhpMyAdmin has an “Export” option that makes this process simple. By going to “Export” you can choose the tables desired, then “Save as File” and “Go.” This allows you to download and save the SQL file for export at your convenience. Be sure to choose a "Save" location that is easy to remember and find. Also, it is extremely important that you backup both server files and database prior to deleting them off of the server.

Replacing An Existing Database

  If the tables already exist they will have to be “dropped.” The simplest way to accomplish this is to delete the database entirely and recreate it in cPanel. Another option is to remove the tables from the database. To accomplish this, go into phpMyAdmin, choose the database from the drop menu, select “Check All” in the right-hand frame and use the command “With Selected: Drop.”

BY: Site-Reference 

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...