1. Attempted to connect my new Drupal 7 installation to a MySQL DB as a user without DROP permissions.
  2. Received error message about DROP permissions and gave the user correct permissions.
  3. Retried and received the following as the 'drupal_install_test'-DB was not created because it couldn't be previously dropped.
  4. Failed to CREATE a test table on your database server with the command CREATE TABLE {drupal_install_test} (id int NULL). The server reports the following message: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'drupal_install_test' already exists.
    Are you sure the configured username has the necessary permissions to create tables in the database?

    That last message would send you in the wrong direction if the server isn't as kind as this one, giving the error quite clearly.

    Perhaps the process that tests for CREATE & DROP permissions should check if the table already exists before attempting to create it again?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David_Rothstein’s picture

Version: 7.0 » 7.x-dev
Component: install system » database system

Interesting bug :) I think this will get more traction in the database system queue, so I'm moving it there.

The current query it runs is this:

CREATE TABLE {drupal_install_test} (id int NULL)

I don't know offhand if it's legal to simply add an IF NOT EXISTS to that (if all database drivers are expected to support that). If not, we could add some mechanism to skip running a database task if a certain condition returns TRUE, and have db_table_exists('drupal_install_test') be the condition for that task, something along those lines.

Crell’s picture

Tricksy...

I'd almost suggest running a table exists, and then either drop-create-drop or just create-drop, depending on the result. Either way we're testing both create and drop access.

Berdir’s picture

These statements are defined in an array, so how would that conditional stuff work?

David_Rothstein’s picture

Status: Active » Needs review
FileSize
2.36 KB

I like @Crell's idea of conditionally doing the drop-create-drop. It's a bit better than mine, since it means we will never skip testing CREATE.

I think something like the attached patch should work?

bryancasler’s picture

After applying patch #4 I was still receiving the same error.

Failed to CREATE a test table on your database server with the command CREATE TABLE {drupal_install_test} (id int NULL). The server reports the following message: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'drupal_install_test' already exists.

I decided to try deleting the "drupal_install_test" table. Now I am getting the following three errors.

Failed to UPDATE a value in a test table on your database server. We tried updating a value with the command UPDATE {drupal_install_test} SET id = 2 and the server reported the following error: SQLSTATE[42S02]: Base table or view not found: 1146 Table '394720_migrate2.drupal_install_test' doesn't exist.

Failed to DELETE a value from a test table on your database server. We tried deleting a value with the command DELETE FROM {drupal_install_test} and the server reported the following error: SQLSTATE[42S02]: Base table or view not found: 1146 Table '394720_migrate2.drupal_install_test' doesn't exist.

Failed to DROP a test table from your database server. We tried dropping a table with the command DROP TABLE {drupal_install_test} and the server reported the following error SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'drupal_install_test'.

As well as a fourth one below the main display.

Uncaught exception thrown in session handler.

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'ssid' in 'where clause': SELECT 1 AS expression FROM {sessions} sessions WHERE ( (sid = :db_condition_placeholder_0) AND (ssid = :db_condition_placeholder_1) ) FOR UPDATE; Array ( [:db_condition_placeholder_0] => 2s9cstk1r9kf2itni42e6orkg0 [:db_condition_placeholder_1] => ) in _drupal_session_write() (line 204 of C:\xampp\htdocs\includes\session.inc).

Screenshot of the four errors. http://awesomescreenshot.com/0a27vfb7e

Berdir’s picture

Are you sure that you actually have these permissions (DELETE, UPDATE, DROP) in that database?

This issue is not about removing them, just handling the case nicely when you give those permissions after it told you about needing them.

bryancasler’s picture

I redid my install, no problems this time around. Could not reproduce this problem.

David_Rothstein’s picture

@animelion, you saw those error messages when installing a new Drupal 7 site, or when updating a Drupal 6 site to Drupal 7?

From the screenshot, it looks like you were updating a Drupal 6 site. If so, maybe the patch has some problem in that scenario. I'm not immediately sure what it would be, but I don't think I tested it in that scenario myself.

bryancasler’s picture

I think what happened is I tried updating from D6 to D7 and an error message was thrown. The update didn't appear to start but the "drupal_install_test" table was now added to the DB. From then on I could not get past the error messages stated in #5 no matter what I did. I went back and did a few other things that I can't recall, but one of them entailed me restoring the DB to a copy that was pre first upgrade attempt.

pcambra’s picture

I'm getting the exact same error trying to update one site

xaccrocheur’s picture

I'm getting this error whith a fresh 7.8 install... Somethings tells me that PDO doesnt like the "{}"s... Investigating

David_Rothstein’s picture

Title: Bad behavior/confusing message when testing DB permissions » Failing to grant 'Drop' privileges to db user during install locks install process without manual db cleanup
Version: 7.x-dev » 8.x-dev
Issue tags: +Needs backport to D7
mkadin’s picture

Tested #4 on drupal 7, works fine.

Re-rolled for drupal 8 and re-tested. Still works.

Guido64-1’s picture

First I recieved also above errors. After I gave the db user the necesary GLOBAL permissions like create drop etc Drupal install worked 100% (Drupal 7.12).

bib_boy’s picture

I had the same issue upgrading from D6 to D7 and the patch at #4 worked for me. thanks.

bib_boy’s picture

In fact I just dropped the 'drop-table-test' table and clicked 'try again'...went past fine.

Status: Needs review » Needs work

The last submitted patch, 13: drop-table-test-1017050-12.patch, failed testing.

alansaviolobo’s picture

Issue summary: View changes
Issue tags: +Needs reroll
DuttonMa’s picture

Assigned: Unassigned » DuttonMa
DuttonMa’s picture

Status: Needs work » Needs review
FileSize
2.22 KB

D8 patch re-rolled, am working on D7 re-roll

Crell’s picture

Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/Database/Install/Tasks.php
@@ -304,5 +318,31 @@ public function validateDatabaseSettings($database) {
+    if (db_table_exists($table)) {

Don't call functions inside classes. Don't we have access to the connection object here? We can get the schema off of that. ($conn->getSchema()->tableExists()). If that's not possible then at the very least use the Database:: class to get it rather than the function.

DuttonMa’s picture

Status: Needs work » Needs review
FileSize
2.25 KB

D8 Patch re-worked to use Database class as suggested, thanks Crell

Crell’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll

Seems reasonable to me, thanks!

It looks like runTestQuery() is also using a db_query(), even though it shouldn't. Can you open a new novice issue for that? (Or go ahead and fix that yourself in a new issue.)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 23: drop-table-test-1017050-14.patch, failed testing.

Status: Needs work » Needs review
DuttonMa’s picture

New novice issue created https://www.drupal.org/node/2358147 and fixed

Crell’s picture

Status: Needs review » Reviewed & tested by the community

Wow, this still passes. :-)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 23: drop-table-test-1017050-14.patch, failed testing.

Crell’s picture

Issue tags: +Needs reroll, +Novice

Rerolling this should be Novice-friendly.

skelly’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
4.62 KB

Re-rolled by a novice...

Crell’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice

Thank you, Novice! :-)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

We can test this now by creating an InstallerTestBase test that creates the drupal_install_test before doing an interactive install.

aks22’s picture

After changing permission of database user and restarting the server i got this worked.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

daffie’s picture

Rerolled the patch.

We have now the Drupal\system\Tests\Installer\InstallerDatabaseErrorMessagesTest. This test installs the table drupal_install_test and tests if the correct erorr-message is displayed. With this patch that should no longer happen.

Status: Needs review » Needs work

The last submitted patch, 37: 1017050-37.patch, failed testing.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Bug Smash Initiative

Checking in on this issue which hasn't has any work for 8 years to find out if it is still relevant.

Is this still relevant to Drupal 10?

Since we need more information to move forward with this issue, I am setting the status to Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!