Reputation: 2449
I have web application, which perfectly working at production server. But this application progressing every day and i frequently need to invite side developers and freelancers for upgrading it. So, every time i find someone, i have to send development version of my apllication and copy of production MySQL database, where i dropped all confidential data manually.
So, the question is: is it possible to make script for auto-making this develop version of database?
UPDATE: I'll try to draw some data. For example, i have Users table:
User table:
name | email | role | phone |
-----------------------------------------------
user2 | [email protected] | guest | 1234567 |
user2 | [email protected] | admin | 1234567 |
user2 | [email protected] | manager | 1234567 |
user2 | [email protected] | topmanager | 1234567 |
But, of course, this table has only real users data. And so on a little bit of simmilar tables. So, i want to make script, that dumps whole production database, drops some important and confidential tables, like Users, Orders, Payments and so on. After this script puts dummy data to those tables, like Users data, which i typed before.
Upvotes: 1
Views: 1072
Reputation: 1034
Do you mean you want to give them a copy of the database with some sections anonymised?
Why not write something like:
UPDATE `mytable` SET `foo` = `bar`
on to anonymise those columns? You could write a PHP script which exports the database and then does this to any relevant tables and columns.
Or am I misinterpreting the question?
Upvotes: 1
Reputation: 22926
If you want to share only the DDLs of your tables (CREATE TABLE statements)
Find the list of tables that you want to share.
Write a shell script to login to mysql and get the DDLs for each table one by one.
DESC TABLE_NAME_1;
DESC TABLE_NAME_2;
Redirect the output to a file.
Share this file.
Upvotes: 0
Reputation: 3849
You can use mysql in command line.
ssh -C user@newhost "mysql -uUSER -pPASS -e 'create database NEW_DB_NAME;'"
&& mysqldump --force --log-error=mysql_error.log -uUSER -pPASS OLD_DB_NAME
| ssh -C user@remotehost "mysql -uUSER -pPASS NEW_DB_NAME"
Upvotes: 4