Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to actually save a mySQL database to Github?

I've been looking around and all I can find is people managing db scripts using github. So they aren't storing the databases, but a list of all commands performed on a database which is then use to sync up two separate databases.

I'm managing my MySQL database using a number of php pages. Is there some way that I can actually store a real database on github along with my website, such that no matter which box I'm working from I'll be using the same database?

like image 410
xcdemon05 Avatar asked Jul 26 '15 05:07

xcdemon05


2 Answers

Why not?! You can commit the database directory to git if you want to. Programmers usually share only code on Git, not data.

Anyway, check this link http://www.mkyong.com/mysql/where-does-mysql-stored-the-data-in-my-harddisk/ to get datadir path on your system. Go there and you can find folders for every database that exists on mySQL. Commit the necessary .frm file to git.

like image 70
Jerry Ajay Avatar answered Nov 15 '22 05:11

Jerry Ajay


You can also create a git hook which can automatically dump the database.

I use this git hook https://github.com/BlurryFlurry/switchdbwhencheckout for switching the database when I switching branches.

like image 44
Ron Avatar answered Nov 15 '22 03:11

Ron