Search code examples
ddev

After upgrading to ddev v0.19.0 I can't do a ddev import-db: Access denied for root


I keep a sql import file that I regularly use to build a site, and after upgrading to ddev v0.19.0, I get this when I do `ddev import-db --src=.tarballs/d7git.sql.gz:

Failed to import database for d7git: Failed to run docker-compose [-f /Users/rfay/workspace/d7git/.ddev/docker-compose.yaml exec -T db bash -c mysql --database=mysql -e 'DROP DATABASE IF EXISTS db; CREATE DATABASE db;' && cat /db/*.*sql | mysql db], err='exit status 1', stdout='', stderr='ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)'


Solution

  • EDIT 2024-02-06: It would be extremely surprising to hit the error described here in any recent version of DDEV. See the docs for more on database management.

    Original answer below:

    This was a result of a bug fix in the mariadb container. Unfortunately it introduces this problem for you.

    Fix it by removing the database entirely and restarting:

    ddev delete --omit-snapshot
    ddev start
    ddev import-db --file=<yourdb.sql.gz>
    

    What's happening is that we're now importing the database using higher (root) privileges to solve a few problems people had. But in v0.18.0, the root user was broken. So if you just remove the whole database and start from scratch, everything works fine (and lots of things that didn't work before too). This is a one-time-per-project fix and you should be able to import without doing this in the future.