Mysql_Module

MySQL and PostgreSQL operations
extends Module\Support\Sql
Methods Summary
public
public
# user_exists( $user , $host = 'localhost' )
public
public
# delete_user( string $user , string $host )
bool delete_mysql_user(string, string[, bool = false]) Delete a MySQL user
public
# store_password( string $sqlpasswd )
bool store_sql_password (string, string)
public
# set_option( string $option , string $value = NULL, string $group = 'client' )
Set MySQL client option Reads from ~/.my.cnf and creates if necessary. Specify a value of null to remove an option.
public
# get_password( )
string retrieve_sql_password (string)
public
# get_option( string $option , string $group = 'client' )
Get option from MySQL client/server configuration
public
public
# import( string $db , string $file )
Import a database from a dump

see

public
# recover_innodb_from_disk( string $db , string $srcdir , bool $force = false )
Recover InnoDB from .ibd files Existing .ibd are NOT overwritten.
public
# list_databases( )
array list_mysql_databases () Queries the db table in the mysql database for applicable grants
public
# change_prefix( string $prefix )
Change account database prefix
public
public
# list_users( )
array list_mysql_users () Lists all created users for MySQL
public
# add_user( $user , $host , $password , int $maxconn = 10, int $maxupdates = 0, int $maxquery = 0, string $ssl = '', string $cipher = '', string $issuer = '', string $subject = '' )
bool add_mysql_user(string, string, string[, int[, int[, int[, string[, string[, string[, string]]]]]]])
public
# get_database_charset( string $db )
Get charset from database
public
# create_database( string $db , string $charset = 'latin1', string $collation = 'latin1_swedish_ci' )
Create a new mysql database
public
# charset_valid( $charset )
public
public
# collation_valid( string $collation )
Validate collation name
public
public
# collation_compatible( string $collation , string $charset )
Verify collation + charset combination are compatible
public
# database_exists( string $db )
Query information_schema for existence of MySQL database
public
# create_database_backend( $db , $charset , $collation )
bool create_mysql_database_backend (string) {@link create_mysql_database}
public
# add_user_permissions( string $user , string $host , string $db , array $opts )
bool add_mysql_user_permissions (string, string, string, array)

Deprecated


see

public
# set_privileges( string $user , string $host , string $db , array $privileges )
Set grants for a MySQL user
public
# delete_user_permissions( $user , $host , $db )
public
# revoke_privileges( string $user , string $host , string $db )
Revoke all privileges on a database from a MySQL user
public
# get_user_permissions( $user , $host , $db )
public
# get_privileges( string $user , string $host , string $db )
Get MySQL grants for a user on a database
public
# version( $pretty = false )
Returns the version of the MySQL server as an integer The form of this version number is main_version * 10000 + minor_version * 100 + sub_version (i.e. version 4.1.0 is 40100)
public
# delete_database( string $db )
Delete MySQL database from system
public
# delete_backup( string $db )
Remove MySQL Backup
public
# assert_permissions( )
Ensure that /var/lib/mysql/ has mysql:<group id> ownership
public
public
# edit_user( string $user , string $host , array $opts )
bool edit_mysql_user(string, string, array) Note when calling through SOAP, all options must be given, otherwise the will default to server preferences.
public
# service_enabled( )
bool service_enabled (string) Checks to see if a service is enabled

Deprecated


see

public
# enabled( )
MySQL/PostgreSQL service enabled on account Checks to see if either MySQL or PostgreSQL is enabled on an account
public
public
# empty( $db )
Database is empty
public
# empty_database( $db )
public
# export( string $db , string|null $file = NULL )
Export a MySQL database
public
# clone( string $from , string $to )
Clone a database
public
# get_database_size( string $db )
Get disk space occupied by database
public
# export_pipe( $db )
Export a db to a named pipe for immediate download
public
# export_pipe_real( $db , $user )
Export a database to a named pipe Differs from export_pipe in that it may only be called internally or from backend, no API access
public
# get_uptime( )
int get_mysql_uptime
public
# add_backup( $db , $extension = 'zip', $span = 5, $preserve = '0', $email = '' )
public
# edit_backup( $db , $extension , $span = '0', $preserve = '0', $email = '' )
public
public
# get_backup_config( string $db )
Fetch MySQL backup task information span => (integer) days between backups hold => (integer) number of backups to preserve next => (integer) unix timestamp of next backup ext => (string) extension of backup email => (string) notify address after backup
public
public
# kill( int $id )
Kill a mysql connection

link

public
# get_processlist( )
Get active mysql connections Array ( [0] => Array ( [id] => 11024 [user] => debug [host] => localhost [db] => debug [command] => Query [state] => User sleep [info] => select sleep(1000) ) )
public
# stats( )
Get basic MySQL server statistics
public
# _cron( Cronus $c )
public
# schema_column_maxlen( string $field )
Get max length of a column in mysql schema
public
# _delete( )
public
# _create( )
public
# _edit( )
public
# _verify_conf( Opcenter\Service\ConfigurationContext $ctx )
public
# _create_user( string $user )
public
# _delete_user( string $user )
public
# _edit_user( string $userold , string $usernew , array $oldpwd )
Methods inherited from Module\Support\Sql
renameDatabasePrefix(), renameDatabasePrefixByType(), pedantize(), renameUserPrefix(), renameUser(), renameUserPrefixByType(), renameUserByType(), installDatabaseService(), uninstallDatabaseService(), _register_temp_user(), _connect_root(), _get_elevated_password(), add_backup_real(), svc_enabled(), edit_backup_real(), list_backups_real(), get_backup_config_real(), delete_backup_real(), _escape(), _preImport(), _postImport()
Methods inherited from Module\Skeleton\Standard
__construct(), setUserParameters(), autoloadModule(), __wakeup(), _invoke(), __debugInfo(), getExportedFunctions(), _reset(), cleanUserParameters(), query()
Constants Summary
public array DEPENDENCY_MAP
# array ( 0 => 'siteinfo', 1 => 'diskquota', )
public string MYSQL_DATADIR
# '/var/lib/mysql'
public int NEW_API_VERSION
# 50720
public int DEFAULT_CONCURRENCY_LIMIT
# 10
public int MAX_CONCURRENCY_LIMIT
# 20
public string EXPORT_CMD
# '/usr/bin/mysqldump --add-drop-table --add-drop-trigger --triggers --events -q -R'
Constants inherited from Module\Support\Sql
DEFAULT_CONCURRENCY_LIMIT , MIN_PASSWORD_LENGTH , MIN_PREFIX_LENGTH , MASTER_USER , DB_BIN2TXT_MULT
Constants inherited from Module\Skeleton\Standard
DEPENDENCY_MAP
Properties Summary
protected $exportedFunctions

# array ( '*' => 2, 'version' => 15, 'get_elevated_password_backend' => 31, 'create_database_backend' => 18, 'delete_database_backend' => 18, 'get_uptime' => 15, 'assert_permissions' => 18, 'set_option' => 15, 'get_option' => 15, 'export_pipe_real' => 18, 'enabled' => 3, 'repair_mysql_database' => 10, 'get_prefix' => 3, 'get_database_size' => 10, 'database_exists' => 10, '_export_old' => 18, 'recover_innodb_from_disk' => 8, 'stats' => 15, )
Properties inherited from Module\Support\Sql
$_tempUsers
Properties inherited from Module\Skeleton\Standard
$exportedFunctions, $username, $password, $domain, $user_id, $group_id, $permission_level, $session_id, $site, $site_id