# Switch to a remote/local database

**URL:** https://community.kinsta.com/t/switch-to-a-remote-local-database/2751
**Category:** Installation
**Created:** [November 16, 2023, 10:58pm UTC](https://community.kinsta.com/t/switch-to-a-remote-local-database/2751 "2023-11-16T22:58:08Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Rosalito\_Udtohan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/rosalito_udtohan/32/1482_2.png) [@Rosalito\_Udtohan](https://community.kinsta.com/u/Rosalito_Udtohan)
#### Post date: [November 16, 2023, 10:58pm UTC](https://community.kinsta.com/t/switch-to-a-remote-local-database/2751/1 "2023-11-16T22:58:08Z")

</div>

I know that devkinsta will create it’s own instance of the database for us to work. But I want to switch to another database that is hosted locally on my machine ([http://localhost/phpmyadmin](http://localhost/phpmyadmin))

Current: Devkinsta uses Adminer on [http://127.0.0.1:15200/](http://127.0.0.1:15200/)

I want to use the ones on mphpmyadmin [http://127.0.0.1](http://127.0.0.1)

Is there a way to do this? is wp-config.php and config.json need to be modified?

 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/9/9a3987db7cd401e6f8aecbb750a6d5a068dcdfa7.png)

---

<div class="post-metadata">

### Author: ![Agus](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/agus/32/1515_2.png) [@Agus](https://community.kinsta.com/u/Agus)
#### Post date: [November 17, 2023, 1:46am UTC](https://community.kinsta.com/t/switch-to-a-remote-local-database/2751/2 "2023-11-17T01:46:12Z")

</div>

Hi again @Rosalito_Udtohan

I’ve never tried this before as DevKinsta already has provided that MySQL/MariaDB service which runs on the `devkinsta_db` container.

While technically we can altering the `wp-config.php` file with different DB name and host also user/password , but I’m not sure if that local WP site will then be manageable correctly through DevKinsta interface.

I would say not to alter the `config.json` file as it’s generated automatically by DevKinsta.

Perhaps you would like to give it a try by altering the following lines in your site’s `wp-config.php` file to something like these:

> define( ‘DB\_NAME’, ‘yourDBnamehere’ );
> 
> /\*\* Database username \*/  
> define( ‘DB\_USER’, ‘youDBuserhere’ );
> 
> /\*\* Database password \*/  
> define( ‘DB\_PASSWORD’, ‘yourDBpasswordhere’ );
> 
> /\*\* Database hostname \*/  
> define( ‘DB\_HOST’, ‘127.0.0.1’ );

then see if you can access your local site URL on your browser if it loads the contents from the database you have on your localhost machine (127.0.0.1) . If it’s not working, then you may want to stick with the previous DB settings (using the default one used in DevKinsta).

Best regards,  
Agus

---

<div class="post-metadata">

### Author: ![Rosalito\_Udtohan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/rosalito_udtohan/32/1482_2.png) [@Rosalito\_Udtohan](https://community.kinsta.com/u/Rosalito_Udtohan)
#### Post date: [November 19, 2023, 4:16am UTC](https://community.kinsta.com/t/switch-to-a-remote-local-database/2751/3 "2023-11-19T04:16:57Z")

</div>

@Agus I’ve tested it and it functions properly. However, there’s a concern that DevKinsta may not accommodate this setup, which could lead to complications when attempting to push or deploy it to myKinsta Live with this kind of setup. What do you think? Maybe I can try and will let you know on Monday.

---

<div class="post-metadata">

### Author: ![Rosalito\_Udtohan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/rosalito_udtohan/32/1482_2.png) [@Rosalito\_Udtohan](https://community.kinsta.com/u/Rosalito_Udtohan)
#### Post date: [November 19, 2023, 10:21pm UTC](https://community.kinsta.com/t/switch-to-a-remote-local-database/2751/4 "2023-11-19T22:21:56Z")

</div>

@Agus Just as I thought. An error occurred when trying to sync from Local to remote myKinsta server using the custom/local database. Error DK0065. Before I stick to the previous DB settings. Maybe there’s still a way to fix this?

 ![image](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/1/1e69d06f1ef95895b3fa0c7ca2a19d2c7023d282.png)

---

<div class="post-metadata">

### Author: ![Rosalito\_Udtohan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/rosalito_udtohan/32/1482_2.png) [@Rosalito\_Udtohan](https://community.kinsta.com/u/Rosalito_Udtohan)
#### Post date: [November 19, 2023, 11:02pm UTC](https://community.kinsta.com/t/switch-to-a-remote-local-database/2751/5 "2023-11-19T23:02:45Z")

</div>

Here’s the log file:  
main.log (290.6 KB)

---

<div class="post-metadata">

### Author: ![Agus](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/agus/32/1515_2.png) [@Agus](https://community.kinsta.com/u/Agus)
#### Post date: [November 20, 2023, 5:39am UTC](https://community.kinsta.com/t/switch-to-a-remote-local-database/2751/7 "2023-11-20T05:39:27Z")

</div>

Hey @Rosalito_Udtohan

Thank you for your reply and update!  
Yeah, that’s what I thought as well and that’s why I mentioned previously:

> While technically we can altering the `wp-config.php` file with different DB name and host also user/password , but I’m not sure if that local WP site will then be manageable correctly through DevKinsta interface.

(I should also have mentioned about the same concern that DevKinsta might not be able to process the site sync from local to remote MyKinsta server or vice versa, due to this custom DB setup in `wp-config.php` file).

I would highly recommend to use the default Database service provided by DevKinsta in your `wp-config.php` (the DB can also be managed through Adminer) instead of using another DB service that’s managed separately on your local computer (through phpMyAdmin) - just to make sure everything will be working properly.

In case you would still want to use that custom local DB in your wp-config.php file, then most likely you will need to do that “push changes” to your MyKinsta server manually (not using DevKinsta’s Sync functions).  
Perhaps with something like the following steps (again it’s still my theory, and I haven’t tried this myself with the custom DB setup/settings like you have):

1. Be sure to [make a manual backup](https://kinsta.com/docs/wordpress-backups/#create-wordpress-backup) of your Staging site first in MyKinsta (just in case).  
Then in DevKinsta, when doing the _Sync → Push to Kinsta_ , you may want to push the **“Files” (and folders) only** and **exclude/un-check the `wp-config.php`** file, and please **also**  **un-check the “Database”** option. Like this for example:  

2. If there’s no issue with the step 1 above, then the next thing is to manually dump/export your local database into a `.sql` file (e.g.: through phpMyAdmin with its DB export tool).

3. Upload that .sql dumped/exported file via [SFTP](https://kinsta.com/docs/connecting-with-sftp/) to your Staging site on Kinsta server (store it under its `~/public` root folder).

4. Once finished, connect via [SSH](https://kinsta.com/docs/connect-to-ssh/) to your Staging site on our server. Then type: `cd ~/public` (so you will be working inside the site’s public folder).  
There, you can double check if you can find that `.sql` file you’ve uploaded via SFTP before (with something like: `ls -la thesqlfilename.sql` .  
Once you’ve confirmed the .sql file is there, you can type the following to import that .sql file to your database on Kinsta server:  
`wp db import thesqlfilename.sql`  
(make sure to change the `thesqlfilename.sql` with your actual .sql. file name).  
You can then free to remove that .sql file you’ve uploaded before (as it’s been imported to your database on our server).

5. Once the .sql import process has completed, you will also need to perform Search and Replace with something like this:  
`wp search-replace 'https://yourlocalsitename.local' 'https://yourstagingsiteurlhere'`  
This will make sure to replace all old local site URL with your actual staging site URL in the database on our server.

You may want to give it a try and see if that would work for you, but again, I would still say to use the default database in DevKinsta instead to avoid such extra manual works.

Best regards,  
Agus

---

<div class="post-metadata">

### Author: ![Rosalito\_Udtohan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/rosalito_udtohan/32/1482_2.png) [@Rosalito\_Udtohan](https://community.kinsta.com/u/Rosalito_Udtohan)
#### Post date: [November 21, 2023, 2:12am UTC](https://community.kinsta.com/t/switch-to-a-remote-local-database/2751/8 "2023-11-21T02:12:09Z")

</div>

Thank you very much for the help @Agus . Will try these, otherwise, will switch to the default database.

---

<div class="post-metadata">

### Author: ![Agus](https://sea2.discourse-cdn.com/flex020/user_avatar/community.kinsta.com/agus/32/1515_2.png) [@Agus](https://community.kinsta.com/u/Agus)
#### Post date: [November 21, 2023, 3:05am UTC](https://community.kinsta.com/t/switch-to-a-remote-local-database/2751/9 "2023-11-21T03:05:07Z")

</div>

You’re most welcome @Rosalito_Udtohan 🙇‍♂️ Alright, sounds good!

Best regards,  
Agus

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex020/uploads/kinsta/original/2X/8/80f8c4e56fecc02327a0964e6bf63a716483529f.png) [@system](https://community.kinsta.com/u/system)
#### Post date: [November 23, 2023, 3:05pm UTC](https://community.kinsta.com/t/switch-to-a-remote-local-database/2751/10 "2023-11-23T15:05:51Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
