Some basic drush commands

Submitted by phannphong on Thu, 02/21/2019 - 17:26
basic drush commands

I will share some basic Drush commands that I usually use:

1. Clear cache / Cache rebuild.

drush cc all (D7) / drush cr (D8)

2. Delete all tables in the database.

drush sql-drop

3. Set password for the account which you know the username

drush upwd <username> --password="<password_you_want>"

Example:

drush upwd admin --password="admin"

By executing the above command line, the password of admin (account with "admin" is username) is admin.

This is a useful command line when you don't know or forget the password of the account.

4. View list the core and the contributed modules have a new version.

drush ups

5. Update core and contributed module with the latest version.

drush up

This command line will update both core and contributed modules at the same time.

If you just want to update for core or individual contributed modules, you'll use:

drush up drupal

(for core)

drush up <module_machine_name_1>, <module_machine_name_2>, <module_machine_name_3>

(Note: module_machine_name_n is the last path of the url link to the contributed module)

You should backup source code and database before running this command line.

6. Revert schema version of core or contributed modules.

drush ev "drupal_set_installed_schema_version('<module_machine_name>', <number_version>)"

Example:

drush ev "drupal_set_installed_schema_version('entityreference', 7002)"

You can find more Drush commands at https://drushcommands.com/

Reference: https://drushcommands.com