by Ken Task.
Appears this strand kinda ignored for some reason, so I'll at least start the discussion diallog/feedback for all those herein.
The more information about the error gives clues and places to check.
Error occurs either during installation OR upgrade ... also backups and restores *IF* the DB user as defined in config.php doesn't have privileges (MySQL terminology) on the DB for the Moodle to be able to create temporary tables.
Assume all posters in this thread use MySQL so ...
In order to see the below, the queries must be made by the 'superuser' for MySQL. Don't use the DB user seen in config.php because it may not have the levels of access it needs.
What does the following mysql query show for the DB user one finds in config.php file of the Moodle site. First the priv's themselves. Next query example for all user 'grants':
mysql> show privileges;
+-------------------------+---------------------------------------+-------------------------------------------------------+
| Privilege | Context | Comment |
+-------------------------+---------------------------------------+-------------------------------------------------------+
| Alter | Tables | To alter the table |
| Alter routine | Functions,Procedures | To alter or drop stored functions/procedures |
| Create | Databases,Tables,Indexes | To create new databases and tables |
| Create routine | Databases | To use CREATE FUNCTION/PROCEDURE |
| Create temporary tables | Databases | To use CREATE TEMPORARY TABLE |
| Create view | Tables | To create new views |
| Create user | Server Admin | To create new users |
| Delete | Tables | To delete existing rows |
| Drop | Databases,Tables | To drop databases, tables, and views |
| Event | Server Admin | To create, alter, drop and execute events |
| Execute | Functions,Procedures | To execute stored routines |
| File | File access on server | To read and write files on the server |
| Grant option | Databases,Tables,Functions,Procedures | To give to other users those privileges you possess |
| Index | Tables | To create or drop indexes |
| Insert | Tables | To insert data into tables |
| Lock tables | Databases | To use LOCK TABLES (together with SELECT privilege) |
| Process | Server Admin | To view the plain text of currently executing queries |
| Proxy | Server Admin | To make proxy user possible |
| References | Databases,Tables | To have references on tables |
| Reload | Server Admin | To reload or refresh tables, logs and privileges |
| Replication client | Server Admin | To ask where the slave or master servers are |
| Replication slave | Server Admin | To read binary log events from the master |
| Select | Tables | To retrieve rows from table |
| Show databases | Server Admin | To see all databases with SHOW DATABASES |
| Show view | Tables | To see views with SHOW CREATE VIEW |
| Shutdown | Server Admin | To shut down the server |
| Super | Server Admin | To use KILL thread, SET GLOBAL, CHANGE MASTER, etc. |
| Trigger | Tables | To use triggers |
| Create tablespace | Server Admin | To create/alter/drop tablespaces |
| Update | Tables | To update existing rows |
| Usage | Server Admin | No privileges - allow connect only |
+-------------------------+---------------------------------------+-------------------------------------------------------+
31 rows in set (0.00 sec)
mysql> show grants;
+---------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '[password]' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
Translation ... on a server that has only one DB user (root) and whose MySQL server setup will talk only to localhost (no outside the server access is setup) ... the user 'root' (which could be admin/Admin/Administrator) @ localhost (server) id'd by password (fake above) with grant optons and those grant options happen to be all privileges. In other words, can do all things to all DB's.
For the official MySQL docs on Grants, please see:
http://dev.mysql.com/doc/refman/5.7/en/grant.html
In:
https://docs.moodle.org/29/en/Step-by-step_Installation_Guide_for_Ubuntu
(used as an example ... not to say you should be useing Ubuntu ... shows the MySQL command to grant priv's:
Section 6 Setup MySQL Server.
'spirit of sharing', Ken