How to connect to a database

From Free Hosting Wiki
(Difference between revisions)
Jump to: navigation, search
[checked revision][checked revision]
 
Line 12: Line 12:
 
: If using a third party script, you will likely need to set the database name, which is your cPanel username, followed by an underscore ("_"), followed by the DB name you created in cPanel.
 
: If using a third party script, you will likely need to set the database name, which is your cPanel username, followed by an underscore ("_"), followed by the DB name you created in cPanel.
 
;port
 
;port
: Some third party scripts ask for a port. The X10 DB servers don't use network connections (indeed, network connections aren't allowed on the free servers), so you shouldn't need to set the port. If the script setup forces you to set a port, use '''3306''' for MySQL or '''5432''' for PostgreSQL, which are the default values.
+
: Some third party scripts ask for a [http://simple.wikipedia.org/wiki/Network_port port]. The X10 DB servers don't use network connections (indeed, network connections aren't allowed on the free servers), so you shouldn't need to set the port. If the script setup forces you to set a port, use '''3306''' for MySQL or '''5432''' for PostgreSQL, which are the default values.
  
 
Remember, the name of all your DB users and databases begin with your cPanel username followed by an underscore, though tables can have any name you wish (subject to the limitations of the DB server you're using).
 
Remember, the name of all your DB users and databases begin with your cPanel username followed by an underscore, though tables can have any name you wish (subject to the limitations of the DB server you're using).

Latest revision as of 18:32, 3 February 2011

With most web scripts, any data created when handling a page request is discarded when the script finishes. To be useful, scripts of consequence need persistant data storage. This usually means interacting with a database. X10 offers MySQL and PostgreSQL database servers, and SQLite embedded DB engine. Since SQLite doesn't run as a server, none of the following is needed for it.

Before you can connect to a database server, you need to create a database and database user using cPanel. Once you've done that, any script that needs to connect to your database will use the following information:

host
localhost
username
Your cPanel username, followed by an underscore ("_"), followed by the DB username you created in cPanel.
password
The password for the DB user you created in cPanel.
database name
If using a third party script, you will likely need to set the database name, which is your cPanel username, followed by an underscore ("_"), followed by the DB name you created in cPanel.
port
Some third party scripts ask for a port. The X10 DB servers don't use network connections (indeed, network connections aren't allowed on the free servers), so you shouldn't need to set the port. If the script setup forces you to set a port, use 3306 for MySQL or 5432 for PostgreSQL, which are the default values.

Remember, the name of all your DB users and databases begin with your cPanel username followed by an underscore, though tables can have any name you wish (subject to the limitations of the DB server you're using).

Personal tools
Namespaces

Variants
Actions