Our experts are always on hand to help answer your questions, get you started, and grow your presence online. You can email us any time
Connect database from your Onion Service
On our Customer Portal, click your Onion Service, and navigate to the "Database" tab.
Scroll to the "Database Credential", you will see your dedicated database connection info and its credential.
This guide outlines three common methods to connect Database from your onion service.
<?php $servername = "db"; $username = "root"; $password = "UE*****De"; // copy your password here // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully"; ?>
<?php $servername = "db"; $username = "root"; $password = "UE*****De"; // copy your password here // Create connection $conn = mysqli_connect($servername, $username, $password); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } echo "Connected successfully"; ?>
<?php $servername = "db"; $username = "root"; $password = "UE*****De"; // copy your password here try { $conn = new PDO("mysql:host=$servername", $username, $password); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo "Connected successfully"; } catch(PDOException $e) { echo "Connection failed: " . $e->getMessage(); } ?>
After the database connection is successful, the message "Connected successfully" is shown.
Our experts are always on hand to help answer your questions, get you started, and grow your presence online. You can email us any time