Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to import database(.sql) to alternative database within single database service #3573

Open
markdorison opened this issue May 25, 2023 · 3 comments
Labels
bug Something aint working right!

Comments

@markdorison
Copy link
Contributor

Apologies for the confusing title!

I am trying to run a multi-site on Lando using a single database service. To date, we have used Lando's recommended approach of creating a separate database service for each of the sites, but with 21 sites and growing, this is causing performance issues. I would like to see if running a single database service, with multiple databases within it would offer better performance.

Lando's db-import documentation examples mention importing into an "auxiliary" database, but this does not seem to work. Is this supported? Could it be?

# Import a file into an auxiliary second database called 'db2'
# with a db called `dataz`
lando db-import dump.zip --host db2
@markdorison markdorison added the bug Something aint working right! label May 25, 2023
@millnut
Copy link

millnut commented May 26, 2023

Hi @markdorison I think the docs are wrong and the command should be;

lando db-import dump.zip --host=db2

@markdorison
Copy link
Contributor Author

Hi @millnut! That would be for importing to the default database on a second db2 service, but I am trying to import to a second (and third, fourth) database on the default database (mariadb) service.

@millnut
Copy link

millnut commented May 26, 2023

Ah I understand so a single service with multiple databases; I don't think you can do it out of the box but may be able to achieve it with a run step?

services:
  database:
    type: mariadb
    creds:
        user: mariadb
        password: mariadb
        database: database
    run:
      # Creates the extra databases as root since the app user does not have those privileges
      - mysql -uroot -e "CREATE DATABASE IF NOT EXISTS db1; GRANT ALL PRIVILEGES ON db1.* TO 'mariadb'@'%' IDENTIFIED by 'mariadb';"
      - mysql -uroot -e "CREATE DATABASE IF NOT EXISTS db2; GRANT ALL PRIVILEGES ON db2.* TO 'mariadb'@'%' IDENTIFIED by 'mariadb';"
      - mysql -uroot -e "CREATE DATABASE IF NOT EXISTS db3; GRANT ALL PRIVILEGES ON db3.* TO 'mariadb'@'%' IDENTIFIED by 'mariadb';"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something aint working right!
Projects
None yet
Development

No branches or pull requests

2 participants