API/Mysql commands

From DreamHost
Revision as of 15:19, 10 March 2012 by Jwwicks (Talk | contribs)

Jump to: navigation, search

MySQL commands

The mysql API module allows managing mysql databases and users.

Commands

mysql-list_dbs

Dump a list of all active MySQL databases on all accounts you have access to.

Values:

(none)

Result:

success
account_id	db	description	home	disk_usage_mb
1234	yourdb_db1	Database 1	haass.tuna.dreamhost.com	0.0078125	
1234	betterdb2435	This one's better	haass.tuna.dreamhost.com	0.0078125

Possible Errors:

(none)


mysql-list_hostnames

Dump a list of all active MySQL hostnames, and the database servers they refer to, for all accounts you can access.

Values:

(none)

Result:

success
account_id	domain	home
1234 mysql.site.dreamhosters.com	haass.tuna.dreamhost.com	
1234 mysql2.site.dreamhosters.com	haass.tuna.dreamhost.com

Possible Errors:

(none)


mysql-add_hostname

Add a MySQL hostname.

Values:

hostname : the full hostname you want to serve as a mysql hostname (unless the domain following the first . is hosted with us, you will not be able to access phpMyAdmin from this hostname).

Result:

success
hostname_added

Possible Errors:

no_hostname
invalid_domain
taken_subdomain
internal_error_adding_hostname
internal_error_could_not_load_domain


mysql-remove_hostname

Remove a MySQL hostname.

Values:

hostname : the full hostname you want to serve as a mysql hostname.

Result:

success
hostname_removed

Possible Errors:

no_hostname
invalid_hostname
internal_error_removing_hostname


mysql-list_users

Dump a list of MySQL users and their privileges, for all databases on all accounts you have access to.

Values:

(none)

Result:

success
account_id	db	home	username	host	select_priv	insert_priv	update_priv	delete_priv	create_priv	drop_priv	index_priv	alter_priv
1234 yourdb_db1	haass.tuna.dreamhost.com	randomuser1		Y	Y	Y	Y	Y	Y	Y	Y	
1234 betterdb2435	haass.tuna.dreamhost.com	randomuser2		Y	Y	Y	Y	Y	Y	Y	Y	

Possible Values:

*_priv : Y or N

Possible Errors:

(none)


mysql-add_user

Add a new MySQL user to a database.

Values:

db: the database to which the user should be added.
user: the username for the new user.
password: the password for the new user.
select: Y or N (optional, default is Y).
insert: Y or N (optional, default is Y).
update: Y or N (optional, default is Y).
delete: Y or N (optional, default is Y).
create: Y or N (optional, default is Y).
drop: Y or N (optional, default is Y).
index: Y or N (optional, default is Y).
alter: Y or N (optional, default is Y).
hostnames: a newline separated list of hosts, in which % is a wildcard, from which the user is allowed to access the databases (optional, default is %.dreamhost.com).

Result:

success
user_added

Possible Errors:

no_db
no_such_db
no_user
invalid_user: reason
user_exists
user_not_lowercase
user_already_on_db
no_password
invalid_password: reason
invalid_select
invalid_insert
invalid_update
invalid_delete
invalid_create
invalid_drop
invalid_index
invalid_alter
internal_error_could_not_load_db
internal_error_adding_user


mysql-remove_user

Rmove a MySQL user from a database.

Values:

db: the database from which the user should be removed.
user: the username for the new user.
select: Y or N.
insert: Y or N.
update: Y or N.
delete: Y or N.
create: Y or N.
drop: Y or N.
index: Y or N.
alter: Y or N.

Result:

success
user_removed

Possible Errors:

no_db
no_such_db
no_user
no_such_user
no_select
invalid_select
no_insert
invalid_insert
no_update
invalid_update
no_delete
invalid_delete
no_create
invalid_create
no_drop
invalid_drop
no_index
invalid_index
no_alter
invalid_alter
internal_error_removing_user