0

I am seeking information on the feasibility of updating a PHP website hosted on an FTP server when the website's database is located on a separate XAMPP server. I am interested in understanding if this can be done and if so, how to go about it. In essence, I want to know if it's possible to maintain and synchronize my website with the database under these circumstances.

I've been researching online, but I haven't found valuable information regarding the possibility of interacting with a MySQL database hosted on XAMPP from a website stored on a remote server using FTP. Even ChatGPT has suggested that such interaction might be impossible based on the available information.

2
  • As long as both the website server and the MySQL server are on the same network and can communicate with each other, then this is straightforward. In fact, this is quite a standard setup. Commented Sep 13, 2023 at 7:43
  • This can be done, one of the ways is : (1) dump your db out from your XAMPP server (2) Send the db dump via FTP to remote site (3) import the db data at the remote site thru simple mysql commands. For all the three steps above, you may automate them by schedulers / cronjobs . Commented Sep 13, 2023 at 7:48

1 Answer 1

1

As long as both the website server and the MySQL server are on the same network and can communicate with each other, then this is straightforward. In fact, this is quite a standard setup.

What you need to do is to ensure that your PHP code includes the connection details for reaching the database server. How you do this depends on if you're using a framework or library. For example, if you're using PDO, then you'll need something like this:

$pdo = new PDO("mysql:host=my_mysql_server;dbname=my_database", 'my_user', 'my_password'); 

You may also need to confirm that your MySQL server's permissions are set to allow connections from your PHP server. Depending on your setup, this might work 'out of the box', but you may need to allow the connection explicitly using something like:

GRANT ALL ON my_database.* TO 'my_user'@'my_php_server'; FLUSH PRIVILEGES; 

See some summary documentation on this here: https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.