Use the same values for the database connection locally and remotely
PHP applications typically use different database connection values locally and on a remote server. MAMP PRO lets you mirror your provider’s database credentials locally, so the same connection values work in both environments.
The key principle: start with the values your hosting provider gives you, then recreate them locally in MAMP PRO.
Example provider credentials
Section titled “Example provider credentials”| Value | |
|---|---|
| Hostname | db52339873412.hosting-data.io |
| Database name | dbs8723017 |
| Username | dbu4919316 |
| Password | 3dft6hfdgjz9hd3skw |
Step 1 – Create the database in MAMP PRO
Section titled “Step 1 – Create the database in MAMP PRO”-
Open MAMP PRO and start the servers.
-
In the Sites list, select the site you want to use the database with.
-
Switch to the Databases tab.
-
Click the + button at the bottom of the database list. The Create database dialog opens.
-
Enter the database name from your provider — in this example:
dbs8723017. -
Expand the After creating the new database section if it is not already open.
-
Enable Grant access to User and enter the username — in this example:
dbu4919316. -
Enter the password in the with Password field — in this example:
3dft6hfdgjz9hd3skw. -
Click Create. The database appears in the list and is linked to the selected site.
Step 2 – Add the remote hostname as an alias
Section titled “Step 2 – Add the remote hostname as an alias”By default, MAMP PRO uses localhost as the MySQL host. To also accept the provider’s hostname locally, add it as an alias for the site.
-
Switch to the General tab of the site.
-
Scroll down to the Aliases section and click the + button.
-
Enter the provider’s hostname — in this example:
db52339873412.hosting-data.io. -
Save the settings with ⌘ S or File › Save. MAMP PRO saves the changes and restarts the servers.
You can now use the same database credentials in your application for both local development and the remote server.
← MySQL