{"id":20176,"date":"2019-08-22T20:59:47","date_gmt":"2019-08-23T01:59:47","guid":{"rendered":"https:\/\/kb.pressable.com\/?post_type=article&#038;p=12414"},"modified":"2025-10-07T12:39:58","modified_gmt":"2025-10-07T17:39:58","slug":"access-wordpress-database-with-pressable","status":"publish","type":"knowledgebase","link":"https:\/\/pressable.com\/knowledgebase\/access-wordpress-database-with-pressable\/","title":{"rendered":"Accessing A WordPress Database with Pressable"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"how-to-access-a-wordpress-database\" data-offset=\"125\" class=\"content-heading toc-content__target\">How to Access a WordPress Database<\/h2>\n\n\n\n<p>For security reasons, we do not allow remote access to a Pressable site&#8217;s database. For more information, please see our <a href=\"https:\/\/pressable.com\/knowledgebase\/service-platform-considerations\/\" target=\"_blank\" rel=\"noopener noreferrer\">Platform and Service Considerations<\/a>.<\/p>\n\n\n\n<p>However, if you wish to connect to your Pressable site&#8217;s database programmatically from within your site, such as via PHP Data Objects (PDO) or MySQLi, you may do so.<\/p>\n\n\n\n<p>If you&#8217;re using PDO or MySQLi within WordPress, you can use the PHP constants defined for database access:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>require 'wp-load.php';<br>$connection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);<\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>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.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can create a <code class=\"\">.php<\/code> file inside the site root <code class=\"\">\/htdocs <\/code>to add custom PHP scripts below<\/li>\n\n\n\n<li>You can then access the script by visiting its URL in your browser (e.g., <code class=\"\">http:\/\/yourwebsite.com\/your_script.php<\/code>).<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php<br>require 'wp-load.php';<br>\/\/ Display WP database credentials<br>echo \"DB NAME :\".DB_NAME .\"&lt;br&gt;\";<br>echo \"DB USER :\".DB_USER .\"&lt;br&gt;\";<br>echo \"DB HOST :\".DB_HOST .\"&lt;br&gt;\";<br>echo \"DB PASSWORD :\".DB_PASSWORD;<\/pre>\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n      <section class=\"container max-width-xl press-structure-alert\">\n\n            <div class=\"alert  alert--is-visible margin-y-md padding-top-md padding-bottom-sm padding-x-sm text-md radius-md js-alert\"\n                 role=\"alert\">\n                  <div class=\"flex gap-sm items-start\">\n                        \n      <svg class=\"icon icon--md margin-right-sm\"\n      viewBox=\"0 0 30 30\">\n       <circle cx=\"15\"\n               cy=\"15\"\n               r=\"14\"\n               fill=\"var(--color-primary)\"\n               opacity=\".2\"><\/circle>\n       <path fill=\"none\"\n             stroke=\"var(--color-primary)\"\n             stroke-linecap=\"round\"\n             stroke-linejoin=\"round\"\n             stroke-width=\"2\"\n             d=\"M15 13v9\"><\/path>\n       <circle cx=\"15\"\n               cy=\"8.5\"\n               r=\"1.5\"\n               fill=\"var(--color-primary)\"><\/circle>\n <\/svg>                        <div>\n                                                                  <span\n                                          class=\"block color-contrast-higher text-lg font-bold margin-bottom-sm line-height-sm\">\n                                          Important:                                    <\/span>\n                              \n                                                                  <p>\n                                          After using the database file, please remove it from the site root directory \/htdocs. Leaving the file there is a security risk.                                    <\/p>\n                                                      <\/div>\n                  <\/div>\n            <\/div>\n\n      <\/section>\n<\/div>\n\n\n<p>If you have any questions, please contact support.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Access a WordPress Database For security reasons, we do not allow remote access to a Pressable site&#8217;s database. For more information, please see our Platform and Service Considerations. However, if [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":60,"template":"","meta":{"content-type":"","footnotes":""},"knowledgebase-categories":[524],"kb-tags":[],"class_list":["post-20176","knowledgebase","type-knowledgebase","status-publish","hentry","knowledgebase-categories-tutorials"],"jetpack_sharing_enabled":true,"meta_box":{"kb_updater":"1"},"_links":{"self":[{"href":"https:\/\/pressable.com\/wp-json\/wp\/v2\/knowledgebase\/20176","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pressable.com\/wp-json\/wp\/v2\/knowledgebase"}],"about":[{"href":"https:\/\/pressable.com\/wp-json\/wp\/v2\/types\/knowledgebase"}],"author":[{"embeddable":true,"href":"https:\/\/pressable.com\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":3,"href":"https:\/\/pressable.com\/wp-json\/wp\/v2\/knowledgebase\/20176\/revisions"}],"predecessor-version":[{"id":47288,"href":"https:\/\/pressable.com\/wp-json\/wp\/v2\/knowledgebase\/20176\/revisions\/47288"}],"wp:attachment":[{"href":"https:\/\/pressable.com\/wp-json\/wp\/v2\/media?parent=20176"}],"wp:term":[{"taxonomy":"knowledgebase-categories","embeddable":true,"href":"https:\/\/pressable.com\/wp-json\/wp\/v2\/knowledgebase-categories?post=20176"},{"taxonomy":"kb-tags","embeddable":true,"href":"https:\/\/pressable.com\/wp-json\/wp\/v2\/kb-tags?post=20176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}