📅  最后修改于: 2023-12-03 15:33:03.991000             🧑  作者: Mango
In WordPress, wp_options
is a database table that stores various settings and configurations of a WordPress installation. Sometimes, due to various reasons such as database corruption, plugin conflicts, or incorrect configurations, the settings stored in wp_options
can become corrupted or incorrect, causing problems for the WordPress site. In such cases, resetting the wp_options
table can help fix the problem. This guide will provide instructions on how to reset wp_options
table in MySQL using SQL statements.
wp_options
table in case of data loss.Connect to the MySQL database using any MySQL client such as phpMyAdmin or command-line interface.
Select the WordPress database from the list of databases.
USE `wordpress_database`;
wp_options
table.TRUNCATE TABLE `wp_options`;
TRUNCATE TABLE
statement, the wp_options
table will be empty. To restore the default settings and values, run the following SQL statements.INSERT INTO `wp_options` VALUES ('autoload','yes'),('blog_charset','UTF-8'),('blog_public','1'),('blogdescription',''),('blogname','My Blog'),('can_compress_scripts',''),('comments_notify','1'),('comments_per_page','50'),('cron',''),('date_format','F j, Y'),('db_version','32806'),('default_comment_status','open'),('default_ping_status','open'),('default_post_edit_rows','40'),('default_post_format','0'),('default_site_locale','en_US'),('default_timezone',''),('dismissed_update_core',''),('dismissed_update_plugins',''),('dismissed_update_themes',''),('edit_another_users_posts',''),('editor_max_image_size',''),('embed_autourls',''),('embed_size_h','360'),('embed_size_w','480'),('gmt_offset','-5'),('gzipcompression','0'),('home',''),('illegal_names',''),('image_default_align','none'),('image_default_link_type','none'),('image_default_size','medium'),('image_default_title',''),('large_size_h','1024'),('large_size_w','1024'),('links_updated_date_format','F j, Y g:i a'),('mailserver_login',''),('mailserver_pass',''),('mailserver_port',''),('mailserver_url',''),('medium_large_size_h','768'),('medium_large_size_w',''),('medium_size_h','300'),('medium_size_w','300'),('migrated',''),('minimum_font_size',''),('month_format','F Y'),('ms_files_rewriting',''),('mshot','1'),('permalink_structure','/my-blog/%year%/%monthnum%/%day%/%postname%/'),('ping_sites','http://rpc.pingomatic.com/'),('post_revisions','5'),('posts_per_page','10'),('posts_per_rss','10'),('privacy','0'),('rewrite_rules',''),('rss_language',''),('rss_use_excerpt','0'),('show_on_front','posts'),('sidebars_widgets',''),('site_icon',''),('siteurl',''),('start_of_week','1'),('sticky_posts','a:0:{}'),('stylesheet',''),('stylesheet_root',''),('template',''),('template_root',''),('timezone_string',''),('use_trackback','1'),('users_can_register',''),('widget_search',''),('widget_text',''),('widget_twentyeleven_ephemera',''),('widget_twentyeleven_featured_page',''),('widget_twentyeleven_recent_comments',''),('widget_twentyeleven_recent_posts',''),('widget_twentyeleven_search',''),('widget_twentyeleven_tabs',''),('widget_twentyeleven_video',''),('widget_twentyeleven_widgets',''),('widget_wpcom_social_media_icons_widget',''),('woocommerce_availability',''),('woocommerce_cart_redirect_after_add','no'),('woocommerce_catalog_columns','4'),('woocommerce_catalog_rows','3'),('woocommerce_enable_coupons','yes'),('woocommerce_enable_review_rating','yes'),('woocommerce_force_ssl_checkout','no'),('woocommerce_hold_stock_minutes',''),('woocommerce_notify_low_stock','yes'),('woocommerce_notify_no_stock','yes'),('woocommerce_price_display_suffix','',''),('woocommerce_product_gallery_columns','4'),('woocommerce_single_redirect_after_add','no'),('woocommerce_stock_email_recipient',''),('woocommerce_stock_unhold_time',''),('woocommerce_tax_based_on','shipping'),('woocommerce_tax_classes',''),('woocommerce_tax_display_cart',''),('woocommerce_tax_display_shop',''),('woocommerce_tax_total_display',''),('woocommerce_version','2.6.4'),('wpstats_version','1.1'),('yoast_installer_redirect_migrated',''),('yoast_tracking_allow_track','no'),('yoast_tracking_anonymize_ip','yes'),('yoast_tracking_dnt_cookie','yes');
wp_options
table has been reset by checking whether the default settings have been restored.SELECT * FROM `wp_options` WHERE `option_name` = 'blogname';
This should return the blog name as 'My Blog,' which was set by the default settings in step 4.
Resetting the wp_options
table can be a useful way to fix problems with WordPress settings and configurations. However, care should be taken to ensure that proper backups are made before resetting the table, as data loss can occur if the reset is done incorrectly.