简体   繁体   中英

Connecting Local Host to online sql database

I have an online reservation booking system (php script) that uses a mySQL database. Part of the script is a back end admin panel for offline reservations.

Is it possible to run a service like XAMPP using local host to access the remote database.

You can connect to remote database by having remote host, db username, db password.

Host name = (use the db server IP address)

Database name = (cpanelUsername_databaseName)

Database username = (cpanelUsername_databaseUsername)

Database password = ( * )

MySQL Connection Port = 3306 (check your)

If you are using cPanel then you need to allow your local IP for DB access first. Login to cpanel, on the main menu of CPanel, Jump down to "Databases" and select "Remote MySQL" Now add your IP address, or IP range with a wildcard such as 12.34.%

Good Luck

Yes. You need login credentials for the remote database as well as it's port and server address (hostname or IP), as you'd expect. The remote host also needs to have permissions granted for that particular user to access the database remotely, which users will not have by default.

Yes it is. Just the way you connect your local database, you can connect to a remote database with valid credentials. Then only thing changes is the hostname parameter.

for an example if your database is hosted on dreamhost, they have hostnames like.. mysql.yourdomain.com . Create a database on your remote server and connect to it as

<?php
mysql_connect('mysql.yourdomain.com','username','password');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM