Drush SQL Query (sql-query, sqlq)

Below you find some examples of how to use the Drush sql-query (alias : sqlq) command.

Show information of user 1:
drush sql-query "SELECT * FROM users where uid=1"

Troubleshooting

error: system() has been disabled for security reasons

To resolve, go to your (local or global) php.ini and temporarily remove 'system' from the disable functions parameter:

Example:

Change
disable_functions = show_source, system, shell_exec, passthru, exec, phpinfo, shell, symlink
To:
disable_functions = show_source, shell_exec, passthru, exec, phpinfo, shell, symlink

Warning: this exposes some security risks, so there must be a better way to do it with PHP, without using the 'system()' function.

Using a custom php.ini
Please see the page Modifying the PHP or PHP configuration that drush runs under for instructions on creating a custom php.ini file for Drush.

Custom version of the php.ini file

You can use something like this to invoke a custom version of the php.ini file you want to use with Drush. The PHP command argument -c ini-file will allow you to specify a custom .ini file to use with Drush.

Subscribe with RSS Subscribe to RSS - SQL queries