This project contains Vagrant config file and couple of bash scripts which will create virtual machine containing MySQL with data files located in synced folder on host machine.
It means you can vagrant destroy
and vagrant up
as many times as you need and MySQL data will still be there.
- Virtual machine, provisioned with help of Vagrant, containing MySQL.
- MySQL install in non-interactive mode.
- As said above, the MySQL data is persistent - you can destroy and re-create VM without losing the data in your DB.
- Setup of access to your MySQL server from host machine.
- Apt-get
update
anddist-upgrade
in non-interactive mode.
- Install VirtualBox virtualizer so you could run virtual machines on your desktop.
- Install Vagrant provisioner so you could create VMs in easier way.
- Get this project files by cloning with
git
executinggit clone https://github.com/jazzfog/mysql-in-vagrant.git
from console or just download zip file. - Open directory with files in console and execute
vagrant up
. - Just wait, in couple of minutes you will have fully functional MySQL server in virtual machine.
- Connect to it from your desktop using ip and port
192.168.100.120:3306
(you can change it inVagrantfile
). By default there is only userroot
with empty password. - Log in into your VM with MySQL by running
vagrant ssh
in console from directory where project files are. Or you can use anyssh
client you prefer and connect using ip and port192.168.100.120:22
, in this case use loginvagrant
and passwordvagrant
to access VM. - Connect to MySQL server from VM by running
mysql -u root
in console (no need to use key-p
) - If you need to add some configuration to MySQL server - edit
provision/my.cnf
file. - If you need to run something every time VM boots - edit
provision/up.sh
file.
- To connect use login
root
and empty password. You can create more users using it. - This instance supposed to be development environment. The fact that root password is empty should state it :)
- However it may give you some ideas how to provision production server automatically.
- The data (MySQL binary files are located in directory
MysqlData
inside project folder). After each start MySQL in VM will pickup those files. - If you want to reset data - just delete directory
MysqlData
. Usually you do not need to re-create VM but you can do it too. - Guest OS/box is "ubuntu/trusty64"
- VM login and password are default for Vagrant:
vagrant
/vagrant
.