Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Mysql server

darthsteven edited this page Dec 8, 2014 · 6 revisions

Parrot comes with a MySQL server instance, that will tune itself to the size of VM it's provisioned on. A default MySQL user is set up for accessing databases from both guest and host OS.

Accessing

You can access the MySQL server from the host machine via port forwarding using the following details:

mysql://root:[email protected]:3306/

So you can use the following command line to connect:

mysql -u root -proot -h 127.0.0.1 -P 3306

From either the guest or host.

Drupal configuration

To use these settings with Drupal you need something like the following in your settings.php:

 $databases['default']['default'] = array(
   'driver' => 'mysql',
   'database' => '{database}',
   'username' => 'root',
   'password' => 'root',
   'host' => '127.0.0.1',
   'port' => 3306,
 );

Auto database import

To make it really easy to import databases into Parrot, you can simply pop a database_name.sql or database_name.sql.gz file into the databases directory on the host and run vagrant provision and Parrot will ensure that there is a database in MySQL called database_name and will import the file into that database, extracting the file on the fly using gzip if needed.

This means that you can easily do a vagrant destroy;vagrant up and effectively reset the VM and databases back to a good working state very quickly.

Database export

If you want to rebuild your VM you may find that you restore old (or empty!) databases instead of the databases with the latest data in them.

If you want to quickly dump all the databases in the VM out into the auto import database folder then you can run the following script and Parrot will mysqldump them all out.

scripts/dump-databases.sh

Default MySQL config

The default MySQL config supplied with Parrot contains some performance optimisations depending on the amount of memory the guest VM has. These are specified in the /etc/mysql/conf.d/parrot.conf file, which is auto-generated by Puppet. Everything else is standard Ubuntu.

We also specify the bind-address as 0.0.0.0, so MySQL is listening on all of the guest's network interfaces.

Clone this wiki locally