How to Access a WordPress Database
For security reasons, we do not allow remote access to a Pressable site’s database. For more information, please see our Platform and Service Considerations.
However, if you wish to connect to your Pressable site’s database programmatically from within your site, such as via PHP Data Objects (PDO) or MySQLi, you may do so.
If you’re using PDO or MySQLi within WordPress, you can use the PHP constants defined for database access:
<?php
require 'wp-load.php';
$connection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
If you are not accessing the database from within WordPress (i.e. via a PHP script that functions outside of WordPress), then you can use the following script to output the database credentials necessary for a PDO or MySQLi connection.
- You can create a
.phpfile inside the site root/htdocsto add custom PHP scripts below - You can then access the script by visiting its URL in your browser (e.g.,
http://yourwebsite.com/your_script.php).
<?php
require 'wp-load.php';
// Display WP database credentials
echo "DB NAME :".DB_NAME ."<br>";
echo "DB USER :".DB_USER ."<br>";
echo "DB HOST :".DB_HOST ."<br>";
echo "DB PASSWORD :".DB_PASSWORD;
After using the database file, please remove it from the site root directory /htdocs. Leaving the file there is a security risk.
If you have any questions, please contact support.