An unofficial Deployer recipe containing a set of useful tasks for interacting with MySQL.
Install via Composer as a dev dependency to your project.
$ composer require --dev pxlrbt/deployer-mysql
For configuring MySQL connection, add the following to your deployer config:
require __DIR__ . '/vendor/pxlrbt/deployer-mysql/recipe/mysql.php';
set('mysql.connection', [
'host' => 'localhost',
'port' => 3306,
'database' => 'your_database_name',
'username' => 'root',
'password' => 'root',
]);
You can modify the dump file and mysqldump
options via:
set('mysql.dump', [
'file' => 'dump.sql',
'options' => [
'--skip-comments'
]
]);
Each option you want to add must be a new entry in the array.
Note: the --skip-comments
option is the only default option set. So, if you don't have any other options for your setup, you can omit this configuration key entirely.
Instead of providing your database credentials inside the deployer config, it's better to load them from an existing config (e.g. .env file).
There is a recipe that autoloads the credentials from Laravels .env
file. Just add the recipe to
your deployer file and your ready to go-
require __DIR__ . '/vendor/pxlrbt/deployer-mysql/recipe/laravel.php';