I am trying to automate the export of a WordPress database. Below is the format of the command and the output (an unexpected error). If you try this on your computer, please replace the tokens my-mysql-user
, my-mysql-password
, my-mysql-server.com
and my-wp-database
with your own data.
$ mysqldump -u"my-mysql-user" -p"my-mysql-password" -h"my-mysql-server.com" "my-wp-database" -r sql-dumps/dump.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"') FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = 'my-wp-database' AND TABLE_NAME = 'wp_commentmeta';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)
The output in the dump.sql file is incomplete:
-- MySQL dump 10.13 Distrib 8.0.19, for Linux (x86_64)
--
-- Host: my-mysql-server.com Database: my-wp-database
-- ------------------------------------------------------
-- Server version 5.5.5-10.3.22-MariaDB-cll-lve
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `wp_commentmeta`
--
DROP TABLE IF EXISTS `wp_commentmeta`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `wp_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`comment_id` bigint(20) unsigned NOT NULL DEFAULT 0,
`meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`meta_value` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`meta_id`),
KEY `comment_id` (`comment_id`),
KEY `meta_key` (`meta_key`(191))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `wp_commentmeta`
--
LOCK TABLES `wp_commentmeta` WRITE;
/*!40000 ALTER TABLE `wp_commentmeta` DISABLE KEYS */;
/*!40000 ALTER TABLE `wp_commentmeta` ENABLE KEYS */;
UNLOCK TABLES;
More information:
$ mysql --version
mysql Ver 8.0.19-0ubuntu0.19.10.3 for Linux on x86_64 ((Ubuntu))
Is it possible that the problem is caused by the difference between versions of the MySQL server and the client?
Having the above error output, what can I do to make the mysqldump
command work well?
Thank you.
I very successfully back up wordpress databases with:
export MYSQL_PWD=[password]
mysqldump -u [user] --routines --triggers --add-locks --disable-keys --single-transaction [databasename]
Passing the password as an environment variable means that it doesn't appear in the process list. For Wordpress, you probably don't need --routines --triggers
, unless you've got some sophisticated plugins that use triggers or custom functions.
It looks to me, though, that your error is most likely related to this line:
mysqldump: Couldn't execute 'SELECT COLUMN_NAME,
JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"') FROM
.COLUMN_STATISTICS WHERE SCHEMA_NAME = 'my-wp-database'
AND TABLE_NAME = 'wp_commentmeta';':
Unknown table 'COLUMN_STATISTICS' in information_schema (1109)
My guess would indeed be that this is an incompatibility between your MySQL server (v5.5) and your mysqldump (v10.13). Can you find a v5.x of mysqldump to try?