Get the App
SLTechnology News&Howtos  ›  Database  › 

Wordpress database transfer

Shulou Source: shulou.com Published: 2022-06-01 10:50:15 10月02日 Update

Background:

Wordpress installation database specified incorrectly, resulting in data on the site are put into the mysql system library.

mysql> show tables from mysql;

+---------------------------+

| Tables_in_mysql |

+---------------------------+

| columns_priv |

| db |

| event |

| func |

| general_log |

| help_category |

| help_keyword |

| help_relation |

| help_topic |

| host |

| ndb_binlog_index |

| plugin |

| proc |

| procs_priv |

| servers |

| slow_log |

| tables_priv |

| time_zone |

| time_zone_leap_second |

| time_zone_name |

| time_zone_transition |

| time_zone_transition_type |

| user |

| wp_commentmeta |

| wp_comments |

| wp_links |

| wp_options |

| wp_postmeta |

| wp_posts |

| wp_term_relationships |

| wp_term_taxonomy |

| wp_termmeta |

| wp_terms |

| wp_usermeta |

| wp_users |

+---------------------------+

The mysql database itself is stored in the mysql library, so we want to put the website data back into the wordpress library.

Thinking:

First, backup the wordpress data in the mysql library to/back/mysql, and then restore the backup data to the wordpress library.

Operation:

Step 1: Write a backup script

[root@localhost mysql]# cat wp_backup.sh

for tname in ` mysql -uroot -p'dong' -e "use mysql;show tables like 'wp_%'"|grep -iv tables`

do

tname_all="$tname_all $tname"

done

#echo $tname_all

mysqldump -uroot -p'dong' mysql $tname_all >/backup/mysql/wp_all_back.sql

Step 2: After verifying the correctness of the script, execute the script

Step 3: Restore the backup data to the WordPress repository

Step 5: Verify Results

mysql> show tables from wordpress ;

+-----------------------+

| Tables_in_wordpress |

+-----------------------+

| wp_commentmeta |

| wp_comments |

| wp_links |

| wp_options |

| wp_postmeta |

| wp_posts |

| wp_term_relationships |

| wp_term_taxonomy |

| wp_termmeta |

| wp_terms |

| wp_usermeta |

| wp_users |

+-----------------------+

12 rows in set (0.00 sec)

Step 6: Modify the WordPress Connection Library

Finally, the website is running normally, and it is over.

For more blogs, please visit www.ayard.com.cn

Tags: Data backup website script database data recovery verification release blog idea data backup more correctness system results background run Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB macOS Redmi Huawei OPPO Reno