1

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.

3 Answers 3

4

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"
Sign up to request clarification or add additional context in comments.

Comments

1

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?

Comments

0

If you want to share only the DDLs of your tables (CREATE TABLE statements)

  1. Find the list of tables that you want to share.

  2. 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;

  3. Redirect the output to a file.

  4. Share this file.

1 Comment

Why so cumbersome? There is the --no-data switch for mysqldump which does exactly that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.