Support » Plugin: Smush Image Compression and Optimization » DB Error- Directory Table doesn’t exist

  • Resolved gastronimo

    (@gastronimo)


    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)
  • Plugin Author Umesh Kumar

    (@umeshsingla)

    Hey @gastronimo,

    Can you just try deactivating and activating the plugin, that should create the table.

    Thanks, Umesh

    @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?

    Plugin Author Umesh Kumar

    (@umeshsingla)

    @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

    @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
    Plugin Author Umesh Kumar

    (@umeshsingla)

    @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

    @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?

    Plugin Author Umesh Kumar

    (@umeshsingla)

    @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

    Thanks @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:
    ————————————–

    @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]!

    Plugin Author Umesh Kumar

    (@umeshsingla)

    Hey @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 Nastia – WPMU DEV Support

    (@wpmudev-support9)

    Hello @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

    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!

    Hey @umeshsingla & @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 Kasia – WPMU DEV Support

    (@wpmudev-support2)

    Hello @gastronimo,

    I’ve pinged @umeshsingla to check this new issue and we will keep you posted as soon we will know more.

    kind regards,
    Kasia

    Plugin Author Umesh Kumar

    (@umeshsingla)

    @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 8 months, 3 weeks ago by  Umesh Kumar.
Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘DB Error- Directory Table doesn’t exist’ is closed to new replies.