I'm copying a Wordpress site from a server to a local Valet environment.
When I export the database, I can see in the wp_options table that the rows such as the site_url etc are present.
Yet when I import the database into Valet via either wp-cli
or phpMyAdmin
, the wp_options table is missing all the usual rows you'd expect to find in a Wordpress site.
Instead there's just a handful of data for transients
etc.
A similar thing happens with other tables as well.
I'm running:
- macOS 10.4.3
- phpMyAdmin 4.9.0.1
- wp-cli 2.2.0
- Laravel Valet 2.3.3
I've been exporting/importing just the wp_options table to speed up the time needed to troubleshoot things.
I've tried altering export/import settings such as compression and maximising output compatibility but to no avail.
My database knowledge is rather limited after that.
If I repeat the same process using a database from a different project, it works fine.
I'll paste sample wp_options data below.
Troublesome wp_options (slightly edited to hide client details):
DROP TABLE IF EXISTS `example_options`;
CREATE TABLE `example_options` (
`option_id` bigint(20) UNSIGNED NOT NULL,
`option_name` varchar(191) COLLATE utf8_unicode_ci DEFAULT NULL,
`option_value` longtext COLLATE utf8_unicode_ci NOT NULL,
`autoload` varchar(20) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'yes'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `example_options` (`option_id`, `option_name`, `option_value`, `autoload`) VALUES
(1, 'siteurl', 'https://www.example.com', 'yes'),
(2, 'blogname', 'Example Site', 'yes'),
(3, 'blogdescription', '', 'yes'),
...
Compared to this dump from a different project which works fine. Note the Wordpress version here is different which changes the order of the rows that are added.
DROP TABLE IF EXISTS `wp_options`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `wp_options` (
`option_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`option_name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`option_value` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
`autoload` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'yes',
PRIMARY KEY (`option_id`),
UNIQUE KEY `option_name` (`option_name`)
) ENGINE=InnoDB AUTO_INCREMENT=2376 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `wp_options` WRITE;
/*!40000 ALTER TABLE `wp_options` DISABLE KEYS */;
INSERT INTO `wp_options` VALUES
(1,'siteurl','https://www.example.com','yes'),(2,'home','https://www.example.com','yes'),
(3,'blogname','Example Site','yes'),
...
Once I've imported the database, browsing to the site results in a Error establishing database connection
error.
If I try to use wp-cli
I sometimes get Error: One or more database tables are unavailable. The database may need to be repaired.
otherwise it's Error establishing database connection
.