Cross-database migration of wordpress databases and cross-database migration of wordpress Databases
Background:
When Wordpress is installed, the database is incorrectly specified, causing data on the website to be stored in 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 data is stored in the mysql database, so we hope to re-store the website data to the wordpress database.
Ideas:
First, back up the wordpress data in the mysql database to/back/mysql, and then restore the backup data to the wordpress database.
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: run the script after verifying the correctness of the script
Step 3: Restore the backup data to the wordpress Library
Step 5: Verify the result
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 library connected to wordpress
The website also runs normally and ends.
My blog will be published in these two places in the future:
1. Blog Park: http://www.cnblogs.com/ayard/
2. ayard: http://www.ayard.com.cn
I am also a beginner. please correct me if anything is wrong.