MySQL commands to speed up your WordPress database

phpMyAdmin is the most common way to manage a WordPress database. It is important to backup and save a copy of your .sql database file before you proceed with any of these commands.

To use phpMyAdmin follow the steps below:

  1. Login to phpMyAdmin panel and select your WordPress database.
  2. Click on the SQL tab which will bring you to a page with a SQL query box.
Deleting all posts from the WordPress database.
DELETE
FROM wp_posts
WHERE post_type = 'revision';
Spam comments can also be deleted using the following SQL command.

DELETE FROM wp_comments WHERE comment_approved = 'spam'>
All comments awaiting approval can be deleted by using the following SQL command.

DELETE FROM wp_comments WHERE comment_approved = '0'

Even after you have removed a plugin, there is data still left inside the post_meta table which is no longer needed. Run the following query to clean this up.
delete from="" wp_postmeta="" where="" meta_key="your-meta-key" ;
After many edits to a post or page, the amount of stored revision can really start to add up. Use this command to delete all revisions.

DELETE
FROM wp_posts
WHERE post_type = 'revision';

To change the URL or domain name used for your WordPress site in 2 easy commands. Login into phpmyadmin and click on the "sql' tab at the top menu.

  1. Paste the below command changing the domains with your domains. This will update all media and post links.
UPDATE wp_posts SET post_content = REPLACE (
post_content,
'old domain URL here',
'new domain URL here');
  1. Paste the below command changing the domains with your domains. This will update main site url and homepage url.
UPDATE wp_options
SET option_value = 'new domain URL here'
WHERE option_value = 'old domain URL here'
 
  • 121 utilizatori au considerat informația utilă
Răspunsul a fost util?

Articole similare

Markdown

You can now add markdown to support tickets at Thexyz. Emphasis **bold** *italics*...

How to edit the htaccess file

The htaccess file is found at the root of your website's files. To access your website files you...

Setting up WebDav with Nextcloud and ownCloud

ownCloud 10 introduced some changes to connecting with WebDav. This tutorial will show you how to...

Forcing Weebly to use SSL

Usually with Weebly sites, the SSL option is only available for business and performance...

Make Thexyz your homepage

You can quickly get to Thexyz Webmail or Thexyz Start Page every time you open your browser by...