MySQL API commands

MySQL API

The following documentation is officially supported by DreamHost. However, if you find any instructions in this article do not function as intended, it's possible it may be out of date. When in doubt, please contact support for further assistance

The mysql API module allows you to manage databases and users.

It's not possible to create a database using the API. Databases can only be created from within the DreamHost panel.

Commands

mysql-list_dbs

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

Command mysql-list_dbs
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

Dumps a list of all active database hostnames, and the database servers they refer to, for all accounts you have access to.

Command mysql-list_hostnames
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

Adds a database hostname.

Command mysql-add_hostname
Values

hostname : The full hostname you want to serve as a database hostname. Unless the domain following the first . is hosted with DreamHost, you won't 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

Removes a database hostname.

Command mysql-remove_hostname
Values

hostname : The full hostname you want to serve as a database hostname.

Result

success
hostname_removed

Possible errors

no_hostname
invalid_hostname
internal_error_removing_hostname

mysql-list_users

Dumps a list of database users and their privileges for all databases on all accounts you have access to.

Command mysql-list_users
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

Adds a new database user to a database.

Command mysql-add_user
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 this list, 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

Removes a database user from a database.

Command mysql-remove_user
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

See also

 

Did this article answer your questions?

Article last updated .