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

Import database #133

Closed
Julime opened this issue Feb 26, 2019 · 10 comments
Closed

Import database #133

Julime opened this issue Feb 26, 2019 · 10 comments

Comments

@Julime
Copy link

Julime commented Feb 26, 2019

I plan to use this as a local development setup. Therefore i need to import the production database. I couldn't find any hint how to do so at startup in this repo.

Should i do this via bin/cli?

@markshust
Copy link
Owner

Yep - just added this to the documentation so it's more apparent:
https://github.com/markshust/docker-magento#database

@Julime
Copy link
Author

Julime commented Feb 27, 2019

This seems to fail for me:

$ bin/cli ls -la | grep sql
1084 -rw-r--r--  1 app app 1106550 Feb 26 08:01 magento.sql

$ bin/cli mysql -h db -umagento -pmagento magento < magento.sql
-bash: magento.sql: No such file or directory

I've tried another way, got another error:

$ bin/bash

$ mysql -h db -umagento -pmagento magento < magento.sql
ERROR 1227 (42000) at line 12508: Access denied; you need (at least one of) the SUPER privilege(s) for this operation

@markshust
Copy link
Owner

markshust commented Feb 27, 2019 via email

@Julime
Copy link
Author

Julime commented Mar 1, 2019

Sorry for bothering you:

$ bin/cli mysql -h db -umagento -pmagento magento < magento.sql
the input device is not a TTY

@markshust
Copy link
Owner

markshust commented Mar 1, 2019 via email

@carlos-reynosa
Copy link

carlos-reynosa commented Apr 9, 2020

@markshust ,

Yep - just added this to the documentation so it's more apparent:
https://github.com/markshust/docker-magento#database

I noticed that on the section you posted you're using root:

bin/clinotty mysql -h db -u root -pmagento magento < dbdump.sql

But in the existing projects section you're using the magento user:

https://github.com/markshust/docker-magento#existing-projects

bin/clinotty mysql -hdb -umagento -pmagento magento < existing/magento.sql

Following the existing projects section commands I kept getting the following permission error when trying to import a database:

ERROR 1227 (42000) at line 2270: Access denied; you need (at least one of) the SUPER privilege(s) for this operation

In order to bypass the error I had to change the user to root. I thought this was kind of confusing. You might want to change the user name to root in the existing projects section of the initial readme in order to reduce confusion if you're just going through the steps.

@verdde
Copy link

verdde commented Apr 12, 2020

This ticket should be reopened.

me@192-168-0-100 ~/P/text.in (master) [1]> bin/clinotty mysql -hdb -umagento -pmagento magento < test.sql
ERROR 1227 (42000) at line 36341: Access denied; you need (at least one of) the SUPER privilege(s) for this operation

@rangerz
Copy link
Contributor

rangerz commented Apr 13, 2020

@Julime @carlos-reynosa @verdde @markshust
For importing database issue for Access denied; you need (at least one of) the SUPER privilege(s) for this operation, it's because sqldump file exists DEFINER=xxx@yyyy.com clause that needs SUPER privilege.

Solution is remove the DEFINER clause from sql dump file or using n98-magerun2.phar db:dump to export your database.

# Solution 1:
mysqldump -h localhost -u user -pPassword database > dbdump.sql
cat dbdump.sql | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' > dbdump_fixed.sql

# Solution 2:
n98-magerun2.phar db:dump dbdump_fixed.sql

And then you can use magento user to import database.

bin/clinotty mysql -hdb -umagento -pmagento magento < dbdump_fixed.sql

Ref:
https://stackoverflow.com/questions/9446783/remove-definer-clause-from-mysql-dumps

@ikslavok
Copy link

ikslavok commented Dec 15, 2020

I can confirm that this works for the latest update:

bin/CLI mysqldump -hdb -uroot -pmagento magento > backup/magento.sql

Everything else is making me wanna dump my mind :)

@blackizlu
Copy link

blackizlu commented Feb 16, 2021

@mrkovalski solution works fine for the latest update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants