Created
July 30, 2012 14:15
-
-
Save mshmsh5000/3207189 to your computer and use it in GitHub Desktop.
Magento command-line script: Read raw MySQL connection info from local.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
MYSQLCMD=$(which mysql) | |
# Read Magento primary connection info | |
DBHOST=$(/PATH/TO/php -r "echo simplexml_load_file('/PATH/TO/app/etc/local.xml', NULL, LIBXML_NOCDATA)->global->resources->default_setup->connection->host;") | |
DBUSER=$(/PATH/TO/php -r "echo simplexml_load_file('/PATH/TO/app/etc/local.xml', NULL, LIBXML_NOCDATA)->global->resources->default_setup->connection->username;") | |
DBPASS=$(/PATH/TO/php -r "echo simplexml_load_file('/PATH/TO/app/etc/local.xml', NULL, LIBXML_NOCDATA)->global->resources->default_setup->connection->password;") | |
DBNAME=$(/PATH/TO/php -r "echo simplexml_load_file('/PATH/TO/app/etc/local.xml', NULL, LIBXML_NOCDATA)->global->resources->default_setup->connection->dbname;") | |
$MYSQLCMD -u $DBUSER -p$DBPASS -h $DBHOST $DBNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment