title: Connect to GoDaddy server database from localhost computer
body: <p>I programmed a website in PHP that uses a MySQL Server through GoDaddy. I have the same code saved on my local computer and sync it with the directory on GoDaddy through an app. I also use XAMPP on my computer to test any changes I make to the website before I make the changes public. However, the <code>localhost</code> server is different and in no way connected with the cPanel GoDaddy server. Therefore, if something new is added to the database on the public server, I would have to</p>
  <ol>
  <li>Download the sql file on the remote phpmyadmin</li>
  <li>Upload this file on the localhost phpmyadmin</li>
  </ol>
  <p>This is an inefficient process, so now I want to use PHP to connect to the GoDaddy server. To do this, I put the IP Address given to me in the GoDaddy hosting page as the host parameter of the <code>mysqli_connect()</code> function.</p>
  <pre><code>// Set the database access information as constants
  define('DB_USER', 'libuc6kfb0jg');
  define('DB_PASSWORD', 'MY PASSWORD');
  define('DB_HOST', 'MY IP ADDRESS');
  define('DB_NAME', 'firstborumdatabase');
  </code></pre>
  <p>This user has all privileges on both the remote and the localhost.
  On <strong>cPanel - Remote MySQL®</strong> I have added the IP Address of my computer's localhost server.</p>
  <pre><code>// Make the connection
  $dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die('Could not connect to MySQL: ' . mysqli_connect_error());
  </code></pre>
  <p>When I put this code in, instead of having 'localhost' as my host, which connects to the local MySQL server of XAMPP, it gives the following error</p>
  <blockquote>
  <p>Could not connect to MySQL: Access denied for user 'libuc6kfb0jg'@'[Sensitive Info]' (using password: YES)</p>
  </blockquote>
  <p>Since I know it is not a permissions problem, the next thing I did was use the PORT parameter. So, I added 3306 to the end to no avail, for it gave me the same error. Lastly, I put in this code as a <code>mysql</code> command into the mysql client from the XAMPP Control Panel, and this gave me the same exact error.</p>
  <p><strong>Stack Overflow Research</strong></p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/23860910/connect-to-server-database-from-localhost">Connect to server database from localhost</a> does not give the same error as me</li>
  <li><a href="https://stackoverflow.com/questions/55133256/connecting-to-online-mysql-database-from-localhost">Connecting to online MySQL database from localhost</a>: I tried changing <a href="http://www.bforborum.com" rel="nofollow noreferrer">www.bforborum.com</a> to the its ip address from the GoDaddy My Hosting Page, and this gave the same error</li>
  <li><a href="https://stackoverflow.com/questions/48369915/cant-connect-to-godaddy-localhost">Can&#39;t connect to godaddy localhost</a> is answered with the same code that I used except using the <code>PDO</code> api and not the <code>mysqli</code> api</li>
  <li><a href="https://stackoverflow.com/questions/6884033/connecting-remote-server-mysql-database-to-localhost">Connecting remote server mysql database to localhost</a> doesn't give any code</li>
  </ul>
  <p>Any help would be greatly appreciated.</p>
  <hr />
  <p><strong>Edit</strong></p>
  <p>I found a flaw: In cPanel, Remote MySQL Database, I added the IP Address that my localhost server is, not my computer's IP Address, if that makes sense. I am now changing the IP Address that I had added in this tool.</p>