Title: DB Error- Directory Table doesn&#8217;t exist
Last modified: February 20, 2018

---

# DB Error- Directory Table doesn’t exist

 *  Resolved [gastronimo](https://wordpress.org/support/users/gastronimo/)
 * (@gastronimo)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/)
 * With Smush Network Activated on my (dev) multiste I keep getting this repeated
   error on just the main site and 2 subsites of my network, and the error log is
   really slowing page load times:
 * [20-Feb-2018 19:18:53 UTC] WordPress database error Table ‘MYSITE.mydb_20_smush_dir_images’
   doesn’t exist for query CREATE TABLE mydb_20_smush_dir_images (id mediumint(9)
   NOT NULL AUTO_INCREMENT,
    path text NOT NULL, resize varchar(55), lossy varchar(
   55), error varchar(55) DEFAULT NULL, image_size int(10) unsigned, orig_size int(
   10) unsigned, file_time int(10) unsigned, last_scan timestamp DEFAULT ‘0000-00-
   00 00:00:00’, meta text, UNIQUE KEY id (id), UNIQUE KEY path (path(191)), KEY
   image_size (image_size)
 * Any ideas what might the problem/solution be? I need to launch soon…
    Thanks 
   in advance!

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/page/2/?output_format=md)

 *  [Umesh Kumar](https://wordpress.org/support/users/umeshsingla/)
 * (@umeshsingla)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-9996794)
 * Hey [@gastronimo](https://wordpress.org/support/users/gastronimo/),
 * Can you just try deactivating and activating the plugin, that should create the
   table.
 * Thanks, Umesh
 *  Thread Starter [gastronimo](https://wordpress.org/support/users/gastronimo/)
 * (@gastronimo)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10003856)
 * [@umeshsingla](https://wordpress.org/support/users/umeshsingla/),
 * Rapid response = great support- unfortunately, ‘Network Deactivating’, then Reactivating,
   and even making a few changes to Smush configurations in one or two of the affected
   sites did NOT seem to work, as the debug log shows the exact same errors.
 * Did I miss something? What else could I try?
 *  [Umesh Kumar](https://wordpress.org/support/users/umeshsingla/)
 * (@umeshsingla)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10006447)
 * [@gastronimo](https://wordpress.org/support/users/gastronimo/), Did you run a
   bulk smush or optimised a lot of images already? If not, delete and re-install
   the plugin to activate and check if that fixes the house.
 * Else, I’d check your site directly.
 * Thanks, Umesh
 *  Thread Starter [gastronimo](https://wordpress.org/support/users/gastronimo/)
 * (@gastronimo)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10011604)
 * [@umeshsingla](https://wordpress.org/support/users/umeshsingla/),
    I had previously
   done a bulk smash on some sites, and manual on others.
 * I finally attempted to Network Deactivate Smushit before deleting it, but it 
   still remained active all the sites individually! I tried again to Network reactivate/
   deactivate, then finally just deleted it from cPanel. Next, I reinstalled the
   plugin and Network Activated it, but checking the debug.log, I now see the error
   repeated but just on the main site of the network:
 *     ```
       WordPress database error Table 'mysite.mydb_smush_dir_images' doesn't exist for query SELECT count(id) FROM mydb_smush_dir_images made by require_once('wp-admin/network/admin.php'), require_once('wp-admin/admin.php'), do_action('settings_page_wp-smush'), WP_Hook->do_action, WP_Hook->apply_filters, WpSmushBulkUi->ui, WpSmushBulkUi->smush_page_header, WpSmushitAdmin->setup_global_stats, WpSmushDir->total_stats
       [25-Feb-2018 01:12:41 UTC] WordPress database error Table 'mysite.mydb_smush_dir_images' doesn't exist for query SELECT path, image_size, orig_size FROM mydb_smush_dir_images WHERE image_size IS NOT NULL  ORDER BY <code>id</code> LIMIT 0, 1000 made by require_once('wp-admin/network/admin.php'), require_once('wp-admin/admin.php'), do_action('settings_page_wp-smush'), WP_Hook->do_action, WP_Hook->apply_filters, WpSmushBulkUi->ui, WpSmushBulkUi->smush_page_header, WpSmushitAdmin->setup_global_stats, WpSmushDir->total_stats
       [25-Feb-2018 01:12:55 UTC] WordPress database error Can't create table 'mysite.mydb_smush_dir_images' (errno: -1) for query CREATE TABLE mydb_smush_dir_images (
       				id mediumint(9) NOT NULL AUTO_INCREMENT,
       				path text NOT NULL,
       				resize varchar(55),
       				lossy varchar(55),
       				error varchar(55) DEFAULT NULL,
       				image_size int(10) unsigned,
       				orig_size int(10) unsigned,
       				file_time int(10) unsigned,
       				last_scan timestamp DEFAULT '0000-00-00 00:00:00',
       				meta text,
       				UNIQUE KEY id (id),
       				UNIQUE KEY path (path(191)),
       				KEY image_size (image_size)
       			) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci made by do_action('admin_init'), WP_Hook->do_action, WP_Hook->apply_filters, WpSmush->admin_init, WpSmushDir->create_table, dbDelta
       ```
   
 *  [Umesh Kumar](https://wordpress.org/support/users/umeshsingla/)
 * (@umeshsingla)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10012657)
 * [@gastronimo](https://wordpress.org/support/users/gastronimo/), Is that possible
   for you to run that query in PHPMyAdmin and let me know what error you’re getting,
   or maybe you can contact your hosting provider to check it.
 * Thanks, Umesh
 *  Thread Starter [gastronimo](https://wordpress.org/support/users/gastronimo/)
 * (@gastronimo)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10017865)
 * [@umeshsingla](https://wordpress.org/support/users/umeshsingla/),
 * Thanks for asking, had to learn how to first! So I used the plugin Query Monitor
   and came up with..pretty much the same as above, plus error codes
    1146 -Table‘
   mysite_mydb_smush_dir_images’ doesn’t exist & 1005 – Can’t create table ‘,ysite_mydb_smush_dir_images’(
   errno: -1).
 * It also showed the specific queries being run by Smushit as:
 * 17 SELECT meta_value
    FROM mmdb_sitemeta WHERE meta_key = ‘wp-smush-networkwide’
   AND site_id = 1
 *  get_network_option()
    wp-includes/option.php:1162
 *  Plugin: wp-smushit 1 0.0004
    18 SELECT meta_value FROM mydb_sitemeta WHERE meta_key
   = ‘wp-smush-last_settings’ AND site_id = 1
 *  get_network_option()
    wp-includes/option.php:1162
 *  Plugin: wp-smushit 1 0.0003
    19 SELECT meta_value FROM mydb_sitemeta WHERE meta_key
   = ‘wdev-frash’ AND site_id = 1
 *  get_network_option()
    wp-includes/option.php:1162
 *  Plugin: wp-smushit
 * Any of this help you at all?
 *  [Umesh Kumar](https://wordpress.org/support/users/umeshsingla/)
 * (@umeshsingla)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10018338)
 * [@gastronimo](https://wordpress.org/support/users/gastronimo/), Thanks a lot 
   for your efforts. This is what I’m looking for “1005 – Can’t create table ‘,ysite_mydb_smush_dir_images’(
   errno: -1).” Though it’s not the complete error.
 * Do you have PHPMyAdmin installed, and is accessible to you? Because it reports
   the proper error, and that way I can figure out what’s up with your site.
 * You have to login to PHPMyAdmin and you need to select the db for your current
   website and then in query tab you just copy paste this:
 * “CREATE TABLE mydb_smush_dir_images (
    id mediumint(9) NOT NULL AUTO_INCREMENT,
   path text NOT NULL, resize varchar(55), lossy varchar(55), error varchar(55) 
   DEFAULT NULL, image_size int(10) unsigned, orig_size int(10) unsigned, file_time
   int(10) unsigned, last_scan timestamp DEFAULT ‘0000-00-00 00:00:00’, meta text,
   UNIQUE KEY id (id), UNIQUE KEY path (path(191)), KEY image_size (image_size) )
   DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci” and run the query. 
   And please get me a screenshot.
 * Let me know if you need any help doing that, or if it is too much for you?
 * Thanks, Umesh
 *  Thread Starter [gastronimo](https://wordpress.org/support/users/gastronimo/)
 * (@gastronimo)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10029969)
 * Thanks [@umeshsingla](https://wordpress.org/support/users/umeshsingla/),
 * Running SQL Query on CREATE TABLE in phpMyAdmin gets me this in the console window:
   —————————————-
   SQL query:
 * CREATE TABLE mydb_smush_dir_images ( id mediumint(9) NOT NULL AUTO_INCREMENT,
   path text NOT NULL, resize varchar(55), lossy varchar(55), error varchar(55) 
   DEFAULT NULL, image_size int(10) unsigned, orig_size int(10) unsigned, file_time
   int(10) unsigned, last_scan timestamp DEFAULT ‘0000-00-00 00:00:00’, meta text,
   UNIQUE KEY id (id), UNIQUE KEY path (path(191)), KEY image_size (image_size) )
   DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
 * MySQL said: Documentation
    #1005 – Can’t create table ‘mysite.mydb_smush_dir_images’(
   errno: -1) (Details…) —————————————————————-
 * Unfortunately, there is no option to expand the ‘(Details…)’ message!!!
 * However… REquerying the same result from within the console gets me a QUERY FAILED
   and an ERROR popup with this message:
    —————————————- Static analysis:
 * 2 errors were found during analysis.
 *  Variable name was expected. (near ” ” at position 10)
    Unrecognized statement
   type. (near “SQL” at position 0)
 * SQL query:
 * SQL query: CREATE TABLE mydb_smush_dir_images ( id mediumint(9) NOT NULL AUTO_INCREMENT,
   path text NOT NULL, resize varchar(55), lossy varchar(55), error varchar(55) 
   DEFAULT NULL, image_size int(10) unsigned, orig_size int(10) unsigned, file_time
   int(10) unsigned, last_scan timestamp DEFAULT ‘0000-00-00 00:00:00’, meta text,
   UNIQUE KEY id (id), UNIQUE KEY path (path(191)), KEY image_size (image_size) )
   DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci MySQL said: Documentation#
   1005 – Can’t create table ‘mysite.mydb_smush_dir_images’ (errno: -1) (Details…)
 * MySQL said: Documentation
    #1064 – You have an error in your SQL syntax; check
   the manual that corresponds to your MySQL server version for the right syntax
   to use near ‘SQL query:
 * CREATE TABLE mydb_smush_dir_images ( id mediumint(9) NOT NULL A’ at line 1
    Switch
   to visual builder Column: Alias: ————————————–
 *  Thread Starter [gastronimo](https://wordpress.org/support/users/gastronimo/)
 * (@gastronimo)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10042525)
 * [@umeshsingla](https://wordpress.org/support/users/umeshsingla/),
 * Good news and bad news:
 * While I was waiting for your reply and solution, I figured out how to make it
   work by simply network deactivating and uninstalling Smushit [bad news], and 
   now I get no more errors. It was like magic [good news]!
 *  [Umesh Kumar](https://wordpress.org/support/users/umeshsingla/)
 * (@umeshsingla)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10042717)
 * Hey [@gastronimo](https://wordpress.org/support/users/gastronimo/),
 * I’m extremely sorry that I wasn’t able to reply timely.
 * > CREATE TABLE mydb_smush_dir_images ( id mediumint(9) NOT NULL AUTO_INCREMENT,
   > path text NOT NULL, resize varchar(55), lossy varchar(55), error varchar(55)
   > DEFAULT NULL, image_size int(10) unsigned, orig_size int(10) unsigned, file_time
   > int(10) unsigned, last_scan timestamp DEFAULT ‘0000-00-00 00:00:00’, meta text,
   > UNIQUE KEY id (id), UNIQUE KEY path (path(191)), KEY image_size (image_size))
   > DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
 *  If you try running this query manually it should work fine for you, and you 
   can install and re-activate Smush.
 * Thanks, Umesh
 *  Plugin Support [Imran – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support9/)
 * (@wpmudev-support9)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10121652)
 * Hello [@gastronimo](https://wordpress.org/support/users/gastronimo/)
 * Hope you’re well!
 * We’ve not heard from you in a while. I’ve marked this ticket as resolved for 
   now, but if you need anything else at all, we’re here for you, please just reopen
   the ticket or create a new one.
 * Have a good day!
 * Cheers,
    Nastia
 *  Thread Starter [gastronimo](https://wordpress.org/support/users/gastronimo/)
 * (@gastronimo)
 * [8 years ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10236847)
 * OK, I got it worked out finally…sorry I should have started my own thread at 
   first, but deeper investigation showed there was already a ghost table- that 
   the db listed as there, but also said it wasnt. So it would not let me create
   new table…
    After I could finally drop the ghost table, in whatever subdomain
   was giving me the error/problem, then I was able to create it anew.
 * Yippeee, SMUSH MULTiSITE ACTIVATED!
 *  Thread Starter [gastronimo](https://wordpress.org/support/users/gastronimo/)
 * (@gastronimo)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10719181)
 * Hey [@umeshsingla](https://wordpress.org/support/users/umeshsingla/) & [@wpmudev-support9](https://wordpress.org/support/users/wpmudev-support9/)!
 * I ran into this same problem a short time ago, and this time could not resolve
   it by plugin deactivation/reactivation, or by simple table deletion and recreation-
   because I got this NEW error suing the same CREATE TABLE query:
 * Static analysis:
    4 errors were found during analysis. 1. An alias was previously
   found. (near “:00’” at position 328) 2. A comma or a closing bracket was expected.(
   near “:00’” at position 328) 3. Unexpected beginning of statement. (near “id”
   at position 362) 4. Unrecognized statement type. (near “UNIQUE KEY” at position
   368)
 * ================================================
    I copied exactly what you gave
   me above (using my real DB id), is there something else in this query that needs
   to be changed?
 * Thanks for looking at this again!
 *  Plugin Support [Amin – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support2/)
 * (@wpmudev-support2)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10722174)
 * Hello [@gastronimo](https://wordpress.org/support/users/gastronimo/),
 * I’ve pinged [@umeshsingla](https://wordpress.org/support/users/umeshsingla/) 
   to check this new issue and we will keep you posted as soon we will know more.
 * kind regards,
    Kasia
 *  [Umesh Kumar](https://wordpress.org/support/users/umeshsingla/)
 * (@umeshsingla)
 * [7 years, 8 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/#post-10723999)
 * [@gastronimo](https://wordpress.org/support/users/gastronimo/), The query is 
   ok just that the timestamp needs to be inside single quotes and not backtick.
   Probably the code formatting is changing quotes to backtick.
 * This should work ok:
 * `CREATE TABLE mydb_smush_dir_images ( id mediumint(9) NOT NULL AUTO_INCREMENT,
   path text NOT NULL, resize varchar(55), lossy varchar(55), error varchar(55) 
   DEFAULT NULL, image_size int(10) unsigned, orig_size int(10) unsigned, file_time
   int(10) unsigned, last_scan timestamp DEFAULT "0000-00-00 00:00:00", meta text,
   UNIQUE KEY id (id), UNIQUE KEY path (path(191)), KEY image_size (image_size) )
   DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci`
 * Thanks, Umesh
    -  This reply was modified 7 years, 8 months ago by [Umesh Kumar](https://wordpress.org/support/users/umeshsingla/).

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/page/2/?output_format=md)

The topic ‘DB Error- Directory Table doesn’t exist’ is closed to new replies.

 * ![](https://ps.w.org/wp-smushit/assets/icon-256x256.gif?rev=3447113)
 * [Smush – Image Optimization, Compression, Lazy Load, WebP & CDN](https://wordpress.org/plugins/wp-smushit/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-smushit/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-smushit/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-smushit/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-smushit/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-smushit/reviews/)

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [smush](https://wordpress.org/support/topic-tag/smush/)
 * [table](https://wordpress.org/support/topic-tag/table/)

 * 16 replies
 * 4 participants
 * Last reply from: [gastronimo](https://wordpress.org/support/users/gastronimo/)
 * Last activity: [7 years, 8 months ago](https://wordpress.org/support/topic/db-error-directory-table-doesnt-exist/page/2/#post-10725591)
 * Status: resolved