Skip to content

Instantly share code, notes, and snippets.

@WaximeA
Last active February 13, 2022 22:15
Show Gist options
  • Select an option

  • Save WaximeA/517f9fac1edf358e1443d40840bec4f3 to your computer and use it in GitHub Desktop.

Select an option

Save WaximeA/517f9fac1edf358e1443d40840bec4f3 to your computer and use it in GitHub Desktop.
Change sql script definers before a local magento database import

How to change the sql script's definers before a local magento database import :

  1. First, you have to open your terminal ;)

  2. You have to install homebrew if it's not already done :

$ brew install grep

  1. Once homebrew downloaded, just enter this command in a terminal :

$ /usr/bin/grep -nw sql/file/path/yourfile.sql -e "DEFINER"

Be carefull /usr/bin/grep if it's you're on a mac. For others user it will be /bin/grep/ (not sure)

It will show you what are the current definers, like that :

DEFINER=`foo`@`XX.X.XX.%`

  1. To finish, use this command line to change currents definers :

$ sed -i -- 's/DEFINER=`foo`@`XX.X.XX.%`/DEFINER=`root`@`localhost`/g' ./sql/file/path/yourfile.sql

You can do the command to show definers again to check if it was updated.

You can also do it in sql if you're already import your bdd :

GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY 'root'; FLUSH PRIVILEGES;

or grant all on *.* to 'root'@'%' identified by 'password' with grant option;

Replace "root" by your definer identifior that you can find when you try to change row on sequelpro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment