Databases
Setting up and testing server-side databases.
All clients receive access to unlimited mySQL databases from their hosting plan.
mySQL administration is made through the user Control Panel ...
Advanced Hosting clients should find the icon to 'mysql databases', scroll down the page and click on phpMyAdmin.
Standard Hosting clients should click on 'web' and then 'mySQL'.
When you create a new database in your Control Panel mySQL section you can give them names of your choice. Your account username will be prefixed to your chosen database name along with an underscore such as ...
username_ChosenDatabaseName
Clients with an Advanced Hosting Plan can connect to their database remotely.
Local Settings
Setup your local software to connect to the host using either your domain name or IP address as ...
www.change-domain.com:3306
255.255.255.255:3306
Check your Welcome Mail for confirmation of these settings.
Test Settings
After you have built your database, you may want to check you can access it. To perform such a check, use your html editor to enter the following code ...
<?php
$conn = mysql_connect("localhost", "db_user", "db_pass");
mysql_select_db("db_name", $conn);
echo $conn;
mysql_close($conn);
?>
Save the script as "mysqlcheck.php" and upload it to the public_html area of your website. Now access the page from any web browser and you should see something like this ...
Resource id #1 (or) Resource id #2
Remember to change the following variables from the script ...
db_user = username assigned to the database
db_pass = password assigned to the user
db_name = name of the database itself
If an error exists, PHP will throw up any messages to alert you of where the error is. View these closely as they are very useful when trying to correct your script.
Allow Connections
You then need to tell the mySQL database to allow connections from your local computer. To do this follow these steps ...
- login to your user Control Panel
- click the icon 'mysql databases'
- scroll down the page
- enter your local IP address to 'allow hosts'
If you don't know your local IP number, check it here: IP Checker
When writing your php/mysql code, it is important you do so in a secure and responsible manner. One aspect to ensure is that your script calls to close each mysql connection after the script has run.
If you do not do this then multiple mysql connections may be open at the same time and this will affect server performance. Periodically we search for bad scripting practices and will contact clients should we find any.
Advanced Hosting Plans come with a database backup and restoration tool. From the Control Panel, find the link to 'backups' and download a backup copy of your database. To restore an existing database, simply upload an old backup file from the same page.
If you want to transfer a third-party database to your Saffas account, start by making a copy and save it as an SQL file. Then login to your Saffas Control Panel, find the link to 'mysql databases' and create a new database to transfer to.
Then go to 'phpMyAdmin', select the database to import to, click the 'import' tab then browse to the location of your .sql file and import.
This will then build the new tables and content within your database.
Please note, this is only effective for importing files up to 2mb in size. Anything more than that and we will need to do it for you.
At this time InnoDB is not enabled on any of our shared or reseller servers for reasons related to stability and other software compatibility.
|