There may be times when you need to export data from a single table and import it into a single table using an existing database phpMyAdmin. In this post, we will discuss how to export data from a single table and import into a single table using phpMyAdmin?
Here is a scenario when such an activity may be needed for better understanding. This is from my practical experience.
So, there is this WordPress website we had, and the theme has to be customized. Since we did not want to disrupt the live site, we took a backup and installed a copy on the development system to further customize the site. During the customization process, we ran into some issues. And to isolate the problem, we disabled some plugins to check if the plugins were interfering with the problem.
The problem was, we were using a WordPress plugin called "Post Views Counter" to display views on each post. During the troubleshooting process described above, we also disabled the "Post Views Counter" plugin (or maybe even deleted it from the plugins page in WordPress). Later when we re-installed / re-enabled the plugin, we found the stats have been reset. The post views were all zeros. And we wanted to retain the values.
After the required customization was done, we needed to bring the stats from the "Post Views Counter" to the live site to the development site, before we upload it to the live server. Note: There could have been another way to do this, but we didn't want to take a risk. More on this described at the end of this post.
So here is what we did: export data from a single table and import into a single table using phpMyAdmin.
How to export data from a single table using phpMyAdmin?
To backup only one particular table in phpMyAdmin, click on the particular table and click Export. It will only export the table and not the entire database.
Activities on the live server:
Logged in to phpMyAdmin
Backed up the entire database (just in case needed)
Clicked on the particular table from the left sidebar (ngk_post_views in this case)
Clicked Export
This exported only the table (ngk_post_views in this case) in .sql file
Now that we have the backup of the particular table (ngk_post_views in this case), we need to restore it to the development server.
How to import data from a single table using phpMyAdmin?
To import data from a single table using phpMyAdmin, the process is the same as importing database. BUT, the table you are importing should not exist. Otherwise, phpMyAdmin will throw an error.
Activities on the development server:
Logged in to phpMyAdmin
Backed up the entire database (very important)
Click on the Database
Then select the table we will import, and click drop (table).
The Select T Database Again, Just In Case It Is Not Selected
Click and Import and Select T Backup File of TABLEDownloaded from Live Server
If Every Thing Gets Better, T Import Solda Success (Unless There Are Other Issues, Whitch Bay DD Note Encounter)
We clicked on the table and checked the values and the counts were restored.
View the posts on the site's front end, and we can see the counters restored.
Now that the post view counts have been restored, we have migrated the site to the live server.
By the way, to upload your WordPress website to live server, you can use plugins like "Duplicator". Here is a previous post on -How to use "How to download a website from live server to development local server | Bangla Tech Jagat
As mentioned above, this could have been achieved in another way.
We could have "dropped" the post views table from the development system of phpMyAdmin and then exported the database. When this is uploaded to the live server, the post views table on the live server database is expected to be as it is. Ensure backups are taken before attempting any of the examples in this post, and at your own risk.
EmoticonEmoticon