Total Pageviews

Friday, 23 August 2013

如何修改WordPress的表前缀

actually, i had the same problem as them above, aand change the default prefix (wp_) manually (one by one) is not a good job, why? ..because i’ve a bunch plugins which has been installed on my own blog, and of course it using wp_ prefix too, one of these are firestat.
but, i am successfully changing the default prefix (wp_) using my own method, see below:
1. backup your wordpress database (i’m using phpmyadmin) to an *.sql file.
2. open that *.sql file (make another copy first) using text editor, then find and replace all “wp_” prefix to “something_”.
3. now, drop all tables of your wordpress databases (don’t drop the database  )
4. import the *.sql file which has been edited before into your wordpress databases.
5. and lastly, edit your
wp-config.php file and change the $table_prefix = ‘wp_’; to $table_prefix = ’something_’;
6. in my case, all plugins will be deactivaed automatically, so login to your blog admin panel, then activated your all plugin.
7. done ! 
it work perfectly for me.. !
这种方法比那种在phpmyadmin上改表前缀的方法要快得多,一步就全部修改完毕(这样看mysql比SQL server和access方便多了啊),不需要再像下面的文章《如何修改Wordpress表前缀》多步修改wp_这个前缀了。而且已安装的插件也不会出问题了。
------------------------------------------
如何修改Wordpress的表前缀

WordPress的表名前缀默认为 wp_,该值为Wordpress安装时指定,安装之后无法更改。但若不得已需要改变时,可以使用以下方法。
  • 将数据库导出。
  • 将表中的所有 wp_ 替换为 wp2_,其中 wp2_` 为新的表前缀。
  • 导入数据库。
  • 修改 wp2_options 表的数据,在第四行左右有个 wp_user_roles,将其修改为 wp2_user_roles
  • 修改 wp2_usermeta 表的数据,将所有的 wp_user_level 修改为wp2_user_level,所有的 wp_capabilities 修改为wp2_capabilities
如果忘记修改 wp2_options 和 wp2_usermeta 中的值,后台管理就无法使用。