Connecting my website to a database
On this guide you will find some examples of how to configure your website's connection to a database at Umbler.
All the database information is available in the Database tab in your Control Panel. To connect to a database at Umbler from an external host, like your local computer, external access to the database must be allowed in the Control Panel.
PHP with MySQL
<?php
$mysqli = new mysqli("mysql000.umbler.com", "user", "password", "database");
?>
PHP with Mongo
<?php
$connection = new MongoClient( "mongodb://user:password@tatooine.mongodb.umbler.com:41091/database" );
?>
Node with MySQL
const mysql = require('mysql');
const connection = mysql.createConnection({
host: 'mysql000.umbler.com',
user: 'user',
password: 'password',
database: 'database'
});
connection.connect((err) => {
if (err) throw err;
console.log('Connected!');
});
Node with Mongo
var MongoClient = require('mongodb').MongoClient
, format = require('util').format;
MongoClient.connect('mongodb://tatooine.mongodb.umbler.com:41091/test', function(err, db) {
if(err) throw err;