Cookbooks
percona
documentation
Resource Percona Mysql Database

percona_mysql_database

Manage Percona MySQL databases and execute SQL queries on them. It works by establishing a control connection to the Percona server using the percona client (be sure it is installed before using this resource).

Actions

  • create - (default) to create a named database
  • drop - to drop a named database
  • query - to execute a SQL query

Properties

NameTypesDescriptionDefaultRequired?
userStringthe username of the control connectionrootno
passwordStringpassword of the user used to connect tono
hostStringhost to connect tolocalhostno
portStringport of the host to connect to3306no
database_nameStringthe name of the database to managename if not specifiedno
encodingStringutf8no
collationStringutf8_general_cino
sqlStringthe SQL query to executeno

When host has the value localhost, it will try to connect using a Unix socket, or TCP/IP if no socket is defined.

Examples

# Create a database
percona_mysql_database 'wordpress-cust01' do
  host '127.0.0.1'
  user 'root'
  password node['wordpress-cust01']['mysql']['initial_root_password']
  action :create
end
 
# Drop a database
percona_mysql_database 'baz' do
  action :drop
end
 
# Query a database
percona_mysql_database 'flush the privileges' do
  sql 'flush privileges'
  action :query
end

The query action will NOT select a database before running the query, nor return the actual results from the SQL query.