Andrew Fletcher published: 27 July 2023 1 minute read
Goal: I want to download a table list to a txt or csv file.
Initially, as a root user I tried using drush
drush sql-dump --tables-list=media_field_data > db-list.sql
Of course as a root user and Drush set-up not as root. failed with
Command 'drush' not found, did you mean:
command 'rush' from deb rush (1.8+dfsg-1.1)
My bad.
Changing the user away from root and running the command again
drush sql-dump --tables-list=media_field_data > db-list.sql
Produced a permission error
bash: db-list.sql: Permission denied
Drush to mysqldump
What about if I move away form Drush and go to mysqldump where I'm able to add extensions that include the database user and name.
mysqldump -u {user} -p {database_name} media_field_data > db-list.sql --no-tablespaces
Accordingly, I received a prompt for the password and success - file saved.
Exploring the option to convert comma's to tabs
mysqldump -u {user} -p {database_name} media_field_data --fields-terminated-by ',' --fields-enclosed-by '"' --fields-escaped-by '\' --no-create-info --tab db-list.sql
While I was prompted for the password, this command failed due to permissions error... as follows:
mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces
mysqldump: Got error: 1227: Access denied; you need (at least one of) the FILE privilege(s) for this operation when executing 'SELECT INTO OUTFILE'
Related articles
Andrew Fletcher
•
05 Apr 2024
Drupal 9 to 10 upgrade an example of the actual steps taken
Continuing on from the Drupal 9 to Drupal 10 upgrade outline written earlier... Upgrading Drupal 9 to Drupal 10. However, the point of difference is this article works through the actual action steps of the upgrade.Planning and testing is critical for the Drupal to version 10 process to...
Andrew Fletcher
•
03 Apr 2024
Using Drush to run SQL commands
To run a SQL command using Drush, use the following sql-query commanddrush sql-query "COMMAND"As an example, in the following I will remove all of the records in the Watchdog. Delete from watchdogTo empty (clear) the watchdog table, which contains Drupal's log messages, using the above noted...
Andrew Fletcher
•
12 Mar 2024
Drush open_basedir restriction error
Drush open_basedir restriction errorPHP Warning: include(): open_basedir restriction in effect. File(/usr/share/drush/includes/startup.inc) is not within the allowed path(s): (/var/www/vhosts/{domain}/:/tmp/) in /usr/share/drush/drush on line 113
PHP Warning: ...