mysql managing capabilities
rsvelko - April 16, 2009 - 15:27
| Project: | Drush |
| Version: | All-Versions-HEAD |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | rsvelko |
| Status: | active |
Jump to:
Description
Is it apropriate to put some mysql managing commands in drush (logically under the sql group of commands)?
I mean (sql taken from phpmyadmin):
"SHOW DATABASES;"
"CREATE USER 'uuuu'@'localhost' IDENTIFIED BY 'pass1';"
#GRANT USAGE ON * . * TO 'user'@'localhost' IDENTIFIED BY '***' WITH MAX_QUERIES_PER_HOUR 0 \ MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
# d +
#CREATE DATABASE IF NOT EXISTS `segments_de` ;
# all privs
#GRANT ALL PRIVILEGES ON `segments_de` . * TO 'segments_de'@'localhost';
# db drop
# DROP DATABASE `segments_de` ;
# u -
# DROP USER 'segments_de'@'localhost';
# d -
# DROP DATABASE IF EXISTS `segments_de` ;Is seems that using the already there sql query command will be best - these are just often used queries with a general scope - they manage db users and whole databases ... tasks done with the admin mysql account - not with the one of the current multisite site...
Thoughts?
PS I began writing a bash script that does this - but thought that it will be nice to use drush as a platform ...
PS2 - If you already know of a standalone script doing just that - please tell me.

#1
Well, we will be working on an install command that ha s awizard where you enter the details for those queries. Other than that, I don't think we want many more command for these beyond sql query and sql CLI. Thats my thoughts anyway.
#2
one of the main uses of this kind of mysql manager (the one I propose ) is to install a new drupal site (at least for me). This overlaps with your install command.
Other uses are to delete a test drupal db (nice if files deleted too - but with care )
and the list continues:
- to move/copy one db to an existing one (or a new one) - when restoring backups etc... (not between multisite sites but in the common case - with --mysql-user admin/root credetintials ... )
- to list db-s and tables in them (to easily delete only certain prefixes) (have working wizard-like shell code for the last one)
So will the install command create mysql user and give him all privs on a db and then reload privs? Password generator would be nice too...
Is there a prototype of the install command - I guess it will be best if it uses sub commands - similar to mine sql samples above - maybe through drush sql cli??
We need to first outline the big picture and then formulate a plan. The provision system has got these kind of tools I remember now - so will we go further and port the rest of the things it can do ?
#3
I have all that stuff in provision already.
The install command currently exists in provision, and will be migrated upstream to Drush. It works for Drupal 5, Drupal 6, Drupal 7 with full support for install profiles and localizations.
Essentially , provision is an extension to Drush for managing the services involved in sites. ie: managing virtual host configuration files, creating databases, etc. etc.
It's also being extended to handle things like DNS registration, email server managements, LDAP provisioning and many many more things.
For a lot of these things you need extended permissions (such as a mysql root user account, or sudo access to apachectl), which makes them not ideal to put in Drush itself, since it would only be useful to a much smaller group of people.
You can download HEAD of provision today, or the 0.2 ALPHA1 release in the next few days, copy it into your ~/.drush folder. Then copy ~/.drush/provision/example.drushrc.php to ~/.drush and edit the settings.
To check if everything is in working order , run 'drush.php provision verify --root="/path/to/a/drupal/root"'.
This will run diagnostics, and test the settings you put into the config file.
You may also choose to use the complete Aegir system, which provides a Drupal based front end to all the configuration directives, and allows you to manage all your sites from a web based interface.
We're still working on the ability to not use parts of the system you don't need (at the moment apache and mysql configuration are kind of forced, but it will be possible in the future to only run the mysql bits if you need to)
#4
I should also mention that due to the nature of the drush_invoke API, it's now possible to hook into any command you need to.
My current db_server commandfile resides at http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/provision/d...
So using the drush_invoke api the current 'provision install' command will just be changed to hook into the drush provided install command instead.
#5
I'm a bit stumped by this step:
> Then copy ~/.drush/provision/example.drushrc.php to ~/.drush and edit the settings.
I'd like to be able to use drush to set up a new drupal site from the command line -- in essence, do the same job as the install.php page. Is this possible with provision as described above?
At DrupalCampUK last weekend some of us were discussing getting this written for Drush -- if the plan is to migrate this from provision module, how best can myself and others help?