• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

securitywing

How to Run MySQL Database Anonymize Script from Linux Bash Shell

by wing

How to run mysql annoymise scripot from bash shell.

To anonymize the production database for using in the test environment,  you can create a simple script that can run from the Linux Bash shell with a single command.

At first download a sample database:

# wget https://github.com/datacharmer/test_db/archive/master.zip

Next, unzip the file

#  unzip master.zip

If zip is not already installed in your Linux box, use either “yum -y run zip” in RedHat or centos or run “apt-get -y install zip” for Debian based Linux Distribution.

# cd test_db-master

mysql -u root -p -h mytestdb.ccowcjsacvpb.eu-west-1.rds.amazonaws.com < employees.sql

once the upload is  complete, you can create your anonymize script. The employees database  has the following tables:

For example, you want to anonymize the title column in the titles table and the name and gender columns in the

employees table. Create a file called script.sql and past the following lines:

 

UPDATE employees.titles SET title=’DevOps’;

UPDATE employees.employees SET first_name=’Super’, last_name=’man’, gender=’F’;

 

Now run the script from the shell:

mysql -u root -p -h mytestdb.ccowcjsacvpb.eu-west-1.rds.amazonaws.com  < script.sql

alternatively, you can run the script after logging into the MySQL shell:

mysql> source script.sql

Ref: https://oracle-base.com/articles/mysql/mysql-running-batch-scripts

Related posts:

  1. Cisco Router Security Check for Auditor
  2. How to Schedule AWS EC2 Start and stop time using Lambda and Cloudwatch
  3. 3 Steps to setup SSH remote Access to EC2 from Cloud9
  4. Why IT Organizations Should Consider Having At Least Two DevOps Engineers or Equivalent Roles?

Filed Under: Off Track

Primary Sidebar

Please help us sharing

Categories

  • AWS
  • Basics
  • Containers
  • Cryptocurrency
  • Cyber
  • Internet Security and Safety
  • IS Audit
  • IT Security Exams
  • Law & Human Rights
  • Network Security Tips
  • Off Track
  • Social Media Governance
  • Tech Comparisons
  • Tech Stack Suitability
  • Telecom
  • Tutorial

CISSP Sample Test

Take a CISSP Sample Test

CISA Sample Test

CISA IT governance Sample test

Please Follow Us

Contact us for Ads

Go to Contact Form

Search

Footer

Copyrights

Protected by Copyscape Duplicate Content Detection Software

Securitywing.com reserves the copyrights of all of its published articles.No contents of this site is permitted to be published to anywhere else in the Internet.If any contents are found in any other websites, securitywing reserves the rights to file a DMCA complaint. But you have the right to use the link of any relevant article of this site to point from your website if you consider that it might improve the quality of your article.

Tags

audit AWS backup basics browser check cisco cloud computer configuration cyber data database email gmail hsrp ids iis informaiton internet kubernetes linux load balancing malware microsoft network protection redundancy risk router security security tips server social media SSL switch test tools vpn vrrp web webserver website windows wordpress

Copyright © 2010-2025 ·All Rights Reserved · SecurityWing.com