Each application container is provided with a database instance that can be used as backend storage for your PHP applications. The database instance is fully compatible with MySQL 5.1, and you can create multiple tables within the one schema (database) provided to you.
Accessing the Database from PHP Code
From within your PHP code, you can access the database using one of PHP's MySQL interfaces (mysql, mysqli or PDO_MYSQL), or of course using Zend_Db with one of the PDO_MYSQL or MySQLi adapters.
Assuming your container name is
mycontainer, you should use the following credentials to connect to your database:
- Database host: mycontainer-db.my.phpcloud.com
- Database port: 3306
- Database schema name: mycontainer
- Database user: mycontainer
- Database password: your container password
You also can use configuration options to set up your connection DSN so you can easily pass applications between Developer Cloud users.
$dsn = sprintf( 'mysql:dbname=%s;host=%s', get_cfg_var('zend_developer_cloud.db.name'), get_cfg_var('zend_developer_cloud.db.host') ); $db = new PDO( $dsn, get_cfg_var('zend_developer_cloud.db.username'), get_cfg_var('zend_developer_cloud.db.password') );
Managing your Database Instance
You can manage your database instance using the provided phpMyAdmin interface, which you can access in your application container control panel, under the "Management" tab.
If you prefer to use a MySQL management tool installed on your local workstation, such as MySQL Workbench or the mysql command line tool, you will need to first establish a tunnel connection to your Container.
Once you have a tunnel connection, simply set your MySQL client program to connect to localhost port 13306 (which will be the local port if you followed the tunneling instructions), and connect using the credentials specified above.
For example, once a tunnel connection is esablished, you can use your local MySQL command line client to connect to your Developer Cloud database instance as so:
mysql -u mycontainer -h 127.0.0.1 -P 13306 -p mycontainer