ERROR 1146 table doesn't exist

ERROR 1146 table doesn't exist

by Billy Zwiener -
Number of replies: 16

"ERROR 1146 table doesn't exist" I'm getting this on import of a backup database to a blank database . Unsure why?

I am playing with backups from a working server hosting moodle 3.7 to an empty linux server with a MySQL server version  5.6.36-82.1 (I was uploading the database BEFORE uploading the moodle folders and stopped when I was getting these database errors that may or may not be problematic?

making a new empty database in cPanel. Then importing the SQL file  the working folder using mySQL commands

mysql> use db_name;
mysql> source backup-file.sql;

Now I guess my question is multi part
1) Do tables not existing matter in the long run?
2) How can tables not exist if it's going into a empty new database just created? Maybe I'm just too new to this to understand but if I'm restoring it from a 
database that functions why isn't this the same database now that its going into a blank new "holder" database?
3) Are these non existent tables remnants from an upgrade long ago and are thus not a big deal?
Thanks for any insight.
version

errors
Average of ratings: -
In reply to Billy Zwiener

Re: ERROR 1146 table doesn't exist

by Ken Task -
Picture of Particularly helpful Moodlers

How was the backup-file.sql created in the first place?

How large is the backup-file.sql ... size wise ... from command line:

ls -l backup-file.sql

Was executing mysqldump commands on a DB whose DB server a little messed up and what I was getting for a sql file was really an sql file showing the errors ... not the tables expected for a dump of the entire DB for a moodle that included drop and create commands.  So an sql file can fool one.

The source command says to execute SQL statements in an sql file but if that sql file doesn't have (for some reason) create lines like the following example:

CREATE TABLE `mdl_analytics_indicator_calc` (
  `id` bigint(10) NOT NULL AUTO_INCREMENT,
  `starttime` bigint(10) NOT NULL,
  `endtime` bigint(10) NOT NULL,
  `contextid` bigint(10) NOT NULL,
  `sampleorigin` varchar(255) NOT NULL DEFAULT '',
  `sampleid` bigint(10) NOT NULL,
  `indicator` varchar(255) NOT NULL DEFAULT '',
  `value` decimal(10,2) DEFAULT NULL,
  `timecreated` bigint(10) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `mdl_analindicalc_staendcon_ix` (`starttime`,`endtime`,`contextid`),
  KEY `mdl_analindicalc_con_ix` (`contextid`) 

KEY `mdl_analindicalc_con_ix` (`contextid`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPRESSED COMMENT='Stored indicator calculations';
/*!40101 SET character_set_client = @saved_cs_client */;

the sql file is doing something else!

Yes, missing tables would matter.

Example ... on a site that doesn't use wiki's, the following tables are present:

mysql> show tables like '%wiki%';
+--------------------------------+
| Tables_in_moodle34ssl (%wiki%) |
+--------------------------------+
| mdl_wiki                       |
| mdl_wiki_links                 |
| mdl_wiki_locks                 |
| mdl_wiki_pages                 |
| mdl_wiki_subwikis              |
| mdl_wiki_synonyms              |
| mdl_wiki_versions              |
| mdlc_wiki                      |
| mdlc_wiki_links                |
| mdlc_wiki_locks                |
| mdlc_wiki_pages                |
| mdlc_wiki_subwikis             |
| mdlc_wiki_synonyms             |
| mdlc_wiki_versions             |
+--------------------------------+
14 rows in set (0.01 sec)

If one attempted to use a wiki in Moodle php code, and no tables were present for wiki's don't think Moodle will generate new tables like that on the fly.

Sooo .... ????

'SoS', Ken

In reply to Ken Task

Re: ERROR 1146 table doesn't exist

by Billy Zwiener -
One backup was created through WHM and sent to Amazon SW3. Another was created from codeguard (pretty sure codeguard holds these on Amazon SW3 as well). I downloaded the one from codeguard using Wget. Uploaded it using PSCP

I did have a wiki a long time ago and don't anymore. So perhaps those tables are simply non existent because the wiki was removed and after updates the updates just kept the tables without any data in them? Perhaps that applies to all of these errors? They're all things from the past that were removed at one time?

The size in the command prompt AFTER importing into mySQL database shows 7279.78 MB
database size command prompt

SQL file size of backup prior to import sitting in working directory of server shows 3,941,315,861 in filezilla (I didnt use filezilla to upload, just to see file size on server)
filezilla
SQL file size prior to import to mySQL database via your syntax from command prompt shows 3,941,315,861
command prompt file size

Thanks for your insight



In reply to Billy Zwiener

Re: ERROR 1146 table doesn't exist

by Ken Task -
Picture of Particularly helpful Moodlers

So perhaps those tables are simply non existent because the wiki was removed and after updates the updates just kept the tables without any data in them?

Well, if one removed/deleted the wiki mod then tables should have been removed as well.

LIke I said before ... site I was looking at has never used any wiki in it.   Tables still existed but contained no data.

Perhaps that applies to all of these errors? They're all things from the past that were removed at one time?

Got me ... would assume if one removed code, the table that had an index ...  the index would be removed as well.

mysql> show indexes from mdl_wiki_pages;

Upgrading that site might be an interesting adventure.

'SoS', Ken

In reply to Ken Task

Re: ERROR 1146 table doesn't exist

by Billy Zwiener -
When I try the syntax "mysql> show indexes from mdl_wiki_pages;" it reads "table doesnt exist"

One thing that you might be able to chime in on... the unizpped file is almost the same exact size as the zipped file? Is that normal? Could this be the cause is that the extraction wasn't properly done?
unzipped file vs zipped file size

It's also worth note that on Codeguards site it says my database size that this backup comes from is 35.5 GB sad

on codeguards site

So this sort of begs for me to wonder... wheres all that database?

In Codeguards Zipped request it says the size of the zip is 3.67 GB... 




So I would think that would uncompress to the 35.5 that it says it is nightly?

I just have this nagging feeling that the whole database is not extracted properly but I also am not terribly skilled in this stuff so your input would be greatly appreciated.

For the record I used this command to unzip it from the PuTTY console window
unzip [filename].zip

Perhaps this is where all goes wrong???

Here are all the other ERROR 1064's 

There were a total of 9 instances of these groupings

mdl_scorm_scoes_track

























Anyway, Thank you again for taking the time to glance at this. I appreciate you
In reply to Billy Zwiener

Re: ERROR 1146 table doesn't exist

by Ken Task -
Picture of Particularly helpful Moodlers

"the unizpped file is almost the same exact size as the zipped file? Is that normal?"

an sql file is text.  Would think a zip of a sql file wouldn't be almost exactly the same.

10839507 Nov 13 08:56 moodle349-db-2019111385600.sql

Zip command to create a zip of an sql file:

[root@sos m34]# zip moodle349-db-2019111385600.zip moodle349-db-2019111385600.sql
  adding: moodle349-db-2019111385600.sql (deflated 86%)

Note 86% deflated ...

[root@sos m34]# ls -1sh moodle349-db-2019111385600.*
 11M moodle349-db-2019111385600.sql
1.5M moodle349-db-2019111385600.zip

Have no idea as to what Codeguard is nor how one would use it ... let alone why!

An incorrect DB dump leads to an incorrect DB import.  Junk out ... junk in.  Pretty simple really.

If one downloads or xfers a txt file (which an SQL dump is) it's possible the file got corrputed on download or xfer.  Zip the .sql file first, then xfer.  And xfer in binary mode ... not ascii.

Looks like you have serveral core tables missing.  No, I have no idea as to what happened to them.    If they are referenced in the SQL file you are importing then they shouldn't be missing.

Bring into a Text editor the .sql file and see what's there ... do a find for InnoDB or a find for character set or collation.   BTW, editing an SQL file with editor is one of those last resort kinda things.

Specified key length too long

This sql file is from what version of Moodle?  And where that database used to reside what was character set/collation +  were all the tables InnoDB?  Key lengths can get whacked.

All that info is in the .sql file dump.   Again ... junk out (mysqldump) ... junk in (mysql import).

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: ERROR 1146 table doesn't exist

by Billy Zwiener -

Thanks Ken, I understand what you're saying of junk out junk in so I have been looking at different dump methods that might show different results. Today I had cPanel create the backup of the database directly and it provided the same import results. Even using a different date. What would the preferred way be of getting a proper mysqldump?

Regarding the -Specified key length too long

This sql file is from what version of Moodle? Came from a 3.7 And where that database used to reside what was character set/collation +  were all the tables InnoDB? Heres a screenshot of the sources environment page. It does show a "check" notification about innoDB and perhaps thats the issue here?

 


In reply to Billy Zwiener

Re: ERROR 1146 table doesn't exist

by Ken Task -
Picture of Particularly helpful Moodlers

If you had ssh access to your server, preferred method of
backing up database would be to use CLI and a command called

'mysqldump'.

Should be able to use DB user and DB password from config.php of the moodle to execute:

mysqldump -u [fromconfig] -p'[fromconfig]' [DBNAME] -> moodle37dump.sql [ENTER]

In command above you replace []'d info above.

The environment check image shows check against 3.7.2 of Moodle.  Update the component - link in upper right hand corner of that screen.   Then set pick list for higher version of moodle and let's see what else might turn red.

RED check isn't good - matter of fact should stop an upgrade to anything higher until it's fixed.

Definitely a factor going forward.

mysql_full_unicode_support#Large_prefix is a setting in your my.cnf file for the DB server.

Please see: https://docs.moodle.org/38/en/MySQL_full_unicode_support

However, the errors you've been getting say keys missing for tables that don't exist - tables for core code - not addons!!!

In a stock moodle 3.7's DB there are approximately 413 tables.

On your server, what does:
mysql> use moodle;  [change moodle to your DB name]
mysql> show tables;

show?

'SoS', Ken

In reply to Ken Task

Re: ERROR 1146 table doesn't exist

by Billy Zwiener -

Updated the environment check to 3.8 and its the same. Only the one "check" shows up


On the test server
mysql> use moodle;  [change moodle to your DB name]
mysql> show tables;

outputs - 387 rows in set (0.00 sec)

I'm going to do a mysql dump as you specified and see how that goes

In reply to Billy Zwiener

Re: ERROR 1146 table doesn't exist

by Billy Zwiener -
I just did a restore from a backup.sql I had from the Moodle 3.0 sources I had (instead of the 3.7) using the above methods I was trying with the 3.7 source and they imported fine. Nothing missing. No ERROR 1146's. That said, These backups seem legitimate as the dumps from the 3.0 site have no issues. It seems like pre upgrade the database was fine, and afterwards, not fine. I guess I'll try an upgrade to 3.8 on the test server and see what happens. Could be wishful thinking but maybe it corrects itself... or perhaps I seek a highly skilled database person to reconstruct my tables! ugh... I guess I wont burden you with hypothetical what if's until I get there smile
In reply to Billy Zwiener

Re: ERROR 1146 table doesn't exist

by Ken Task -
Picture of Particularly helpful Moodlers

A 3.0 is NOT a 3.8 ... probably many changes.  The 3.0 might not have any missing tables, so the import on new server should work.  One cannot upgrade a 3.0 site to a 3.8 in one swoop.

I do think you are missing the point ... unless I am just completely mis-understanding ... let me re-phrase ...

IF export minus missing tables ... import will also = missing tables.

MySQL DB server knows nothing about Moodle except what it's been told about a DB for Moodle - the sql statements in the sql file.

"...perhaps I seek a highly skilled database person to reconstruct my tables!"

That, I would think, certainly not done for free ... and might be a very expensive lesson.

Reconstruction of tables ... columns in them you could do with some effort **but** those tables would not contain any data.   Even the most skilled database person can't manufacture useful data .. if it doesn't exist.   Or ... maybe they could and you'll never know!

How would that affect your new Moodle?  Only if you did **not** use mods/blocks/themes/reports related to those missing tables in old site, you might get away with that.  But could be a ticking time bomb too!

The more important question ... how did those tables disappear?

Might consider hiring someone to admin your Moodle (no am not volunteering).  You can can advertise in Moodle jobs.

Or host with a Moodle Partner where you only do the admin in the Moodle interface and the MP does all the updating/upgrading/ installing of plugins, maintaining and backing up of moodle, etc.

'SoS', Ken

In reply to Ken Task

Re: ERROR 1146 table doesn't exist

by Billy Zwiener -
Ok, for anyone who comes across this thread and wants resolve to a situation like this it was a relatively easy fix after many days of puzzle pieces.

1) There was nothing wrong with any of the backups so don't assume its gloom and doom
2) Contact your hosting support (in my case this was siteground) and show them the moodle environment page. In my case the database settings (like antelope...which was sitegrounds default... and barracuda could NOT be changed by me (even on the VPS I was paying for) because I did not have admin rights to change things like this. Once the settings were changed on sitegrounds end I deleted the database, created a new one in cPanel, re-imported the SQL file with no errors, no missing tables. Site worked as expected. 7 day wild goose chase ends ;)
Average of ratings: Useful (2)
In reply to Billy Zwiener

Re: ERROR 1146 table doesn't exist

by Ken Task -
Picture of Particularly helpful Moodlers

Congrats! 

And to add 2 cents more for those on VPS hosting. 

Know the super user credentials to your DB server ... login/password.  If you cannot see that info in cPanel or whatever provider has given you as a tool to admin server, you will have to inquire with helpdesk for that info. 

Other wise, one does not have full control of a server that is supposed to be a virtual private system where you, the paying customer, isn't getting what they paid for!

Siteground is the but one of those providers (have seen around 4 now) that do not share that info with customers that should have that information.

End 2 cents.

'SoS', Ken


In reply to Billy Zwiener

Re: ERROR 1146 table doesn't exist

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
> In my case the database settings (like antelope...which was sitegrounds default... and barracuda could NOT be changed by me (even on the VPS I was paying for) because I did not have admin rights to change things like this.

What does 'P' stand for in their VPS?
In reply to Visvanath Ratnaweera

Re: ERROR 1146 table doesn't exist

by Billy Zwiener -
P stands for Private... Virtual Private Server. VPS. The hierarchy of power on hosting that I have seen is shared hosting (weakest) < VPS < Dedicated Server (most powerful). Having a VPS is supposed to be an affordable option to a using a fully dedicated server. A dedicated server (fully run and dedicated to you) gives you more control but is also more expensive. A VPS is supposed to give you root access (from most hosts) however with siteground I was not provided root access and had to delegate those commands to their support team. This could be easy if you can explain to their support, that you need this done by a higher level support person (usually). Again, I'd just send them screenshots of the moodle environment page and ask them to make the environment compatible according to that. On shared hosting this would usually not be able to be done because you're literally sharing a server and thus them changing settings for you would affect other clients on that server, but on a VPS or Dedicated server it should be controllable by you because you're paying for that level of control... and other clients are not sharing the same space.
In reply to Billy Zwiener

Re: ERROR 1146 table doesn't exist

by Ken Task -
Picture of Particularly helpful Moodlers

Siteground kinda confusing ... but .. overall ... not bad, IMHO (I don't work for them nor do I host with them).

Some info for those who find this thread and VPS 'discussion' ...

https://www.siteground.com/semi_dedicated_hosting.htm

"Our GoGeek plan is the best option between standard shared hosting and the much more expensive dedicated solutions. The GoGeek users take advantage of our state-of-the-art shared server infrastructure, which is highly optimized for speed. At the same time they are accommodated on separate machines with fewer accounts. If you have a highly visited website, if its performance is critical for your business and if you do not have the budget for an expensive dedicated solution, our GoGeek plan is the best semi-dedicated option!"

https://www.wp-tweaks.com/siteground-vps-hosting-gogeek/#siteground-vps-pros-and-cons

Since the VPS plan is basically GoGeek, no – you can’t upgrade or downgrade your SiteGround VPS.

Do I Get Root Access to SiteGround VPS?
Much like Apple, SiteGround tries to manage everything for you. Their philosophy is that you don’t need root access to your server, because you have all the tools to do without it. So unless you purchase a SiteGround dedicated server, you’re not going to get full root access to your installation.


However, you can get SSH shell access. It’s a simple matter to generate the public and private key combinations. You can read my complete tutorial on how to get SSH access on SiteGround. But the permissions you get are for a regular user – not root.


Explanation of the Terms Used

Script Executions

A “script” is a a program or process. Every PHP file ending with “.php” for example is a script. SiteGround’s script execution limits refer to the number of scripts your account processes for a given period of time. The quota goes up as your plan grows and you get more resources for your sites.

Inode Limits

And “inode” is a reference to a file or folder. Each plan has a specific number of inodes it allows. The more expensive plans allow you to have many more files and folders.

Some potential issues?

Cron job in Moodle
Recommendations are once per minute.
Not all of cron runs ... check task schedule.

Inode count - all directories in current location:

find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn

In a pretty much stock M37 code sandbox - only 4 users and 5 courses:

[root@sos moodle37]# find . | wc -l
25570

And a break down of code directory:
find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn

   9033 ./lib
   3843 ./mod
   1937 ./admin
   1244 ./pix
   1207 ./question
   1037 ./blocks
    705 ./install
    542 ./grade
    519 ./backup
    475 ./course
    455 ./repository
    438 ./enrol
    417 ./report
    348 ./theme
    334 ./message
    316 ./auth
    226 ./filter
    210 ./cache
    207 ./availability
    205 ./calendar
    202 ./user
    150 ./media
    125 ./customfield
    107 ./badges
    102 ./privacy
     94 .
     92 ./analytics
     91 ./search
     90 ./.git
     87 ./portfolio
     73 ./webservice
     72 ./lang
     68 ./competency
     65 ./files
     62 ./tag
     55 ./dataformat
     48 ./group
     45 ./completion
     35 ./cohort
     33 ./mnet
     28 ./blog
     21 ./login
     20 ./notes
     18 ./favourites
     17 ./rating
     15 ./local
     15 ./comment
     14 ./my
     10 ./plagiarism
      9 ./iplookup
      7 ./rss
      1 ./userpix
      1 ./error

Data directory is where this might bite ya:
Same site as above

[root@sos moodle37data]# find . | wc -l
7032
Lions share of data dir:

   5099 ./filedir
   1344 ./cache
    317 ./localcache
    232 ./lock
     16 .
      9 ./temp
      6 ./models
      2 ./repository
      2 ./lang
      2 ./environment
      1 ./sessions
      1 ./muc
      1 ./geoip

A K12 site 3.5.9 (Build: 20191111)' on VMWare
Mem:  16333820k total, 15854088k used,   479732k free
Size  Used Avail Use% Mounted on
50G   17G   31G  36% /
2.0T  1.3T  620G  67% /home

9026 users 307 courses mostly HS (9-12) and AP courses where there are multiple
teachers assigned to the courses.  17 addons

Code:

[root@moodle moodle]# find . | wc -l
27657

data directory

[root@moodle Moodle]# find . | wc -l
233751

Break down of moodledata ...

[root@moodle Moodle]# find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn
 204806 ./filedir
  14746 ./lock
   4956 ./lang
   3702 ./mdeploy
   3582 ./filter
   1649 ./cache
    212 ./localcache
     36 ./repository
     19 .
     16 ./sessions
     14 ./temp
      6 ./admin_report_customsql
      5 ./models
      2 ./environment
      1 ./muc
      1 ./geoip


Cron Job

/usr/bin/php /var/www/html/moodle/admin/cli/cron.php >/var/log/moodle_cron.log 2>&1: 696 Time(s)

Brief apache service ... this from a Saturday ... and 'holiday':

 167.15 MB transferred in 5882 responses  (1xx 0, 2xx 5524, 3xx 245, 4xx 113, 5xx 0)
     138 Images (7.04 MB),
      26 Documents (22.10 MB),
    4241 Content pages (113.68 MB),
       3 Redirects (0.00 MB),
    1474 Other (24.33 MB)

Robots 7 logged
    Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) 1 Time(s)
    Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0) 27 Time(s)
    Mozilla/5.0 (compatible; DotBot/1.1; http://www.opensiteexplorer.org/dotbot, help@moz.com) 1 Time(s)
    Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) 1 Time(s)
    Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/8.0.2
Safari/600.2.5 (Applebot/0.1; +http://www.apple.com/go/applebot) 1 Time(s)

There was another poster in forums concerned about inode limits and asked where he could remove files safely.

'SoS', Ken

In reply to Ken Task

Re: ERROR 1146 table doesn't exist

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
@Billy,
> A VPS is supposed to give you root access (from most hosts)

That is how I understand VPS. Wikipedia comes close to it: "A VPS runs its own copy of an operating system (OS), and customers may have superuser-level access to that operating system instance, so they can install almost any software that runs on that OS. "

> however with siteground I was not provided root access and had to delegate those commands to their support team.

Then it could be a _managed_ VPS. I don't know (I know only VPS with full root-access.) In any case, I would call a place, where I need to take permission before doing fully genuine things, _private_.

@Ken

"Semi-dedicated" https://www.siteground.com/semi_dedicated_hosting.htm ? Like part-time honest? Too much for me!
;-?