mysqldump script without hardcode password


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting mysqldump script without hardcode password
# 1  
Old 12-20-2008
mysqldump script without hardcode password

OS: Linux ambglx02 2.6.16.60-0.21-default #1 Tue May 6 12:41:02 UTC 2008 i686 i686 i386 GNU/Linux
Shell: bash

Currently I have a mysqldump script to backup my mysql database, the command is as below:

/opt/novell/mysql/bin/mysqldump --add-drop-table -u root -p[password] -h [hostname] mydb > /home/john/mydb.sql

I need to create a script without hardcoding the password, any idea how to achieve this?

FYI, I will need to put the script into crontab to do scheduling.
# 2  
Old 12-20-2008
Quote:
Originally Posted by bulkbiz
OS: Linux ambglx02 2.6.16.60-0.21-default #1 Tue May 6 12:41:02 UTC 2008 i686 i686 i386 GNU/Linux
Shell: bash

Currently I have a mysqldump script to backup my mysql database, the command is as below:

/opt/novell/mysql/bin/mysqldump --add-drop-table -u root -p[password] -h [hostname] mydb > /home/john/mydb.sql

I need to create a script without hardcoding the password, any idea how to achieve this?

FYI, I will need to put the script into crontab to do scheduling.

No one can help?
# 3  
Old 12-21-2008
setup a .my.cnf file. see the documentation for details.
# 4  
Old 12-21-2008
Quote:
Originally Posted by frank_rizzo
setup a .my.cnf file. see the documentation for details.
but this require me to hardcode my password in the my.cnf, it makes no difference for me, I can't hard code all password. IT Auditors will never allow that.
# 5  
Old 12-21-2008
I don't think you can get around it. This is much better then using the password on the command line. The file would be protected so only the mysql user and root could read it. It is not uncommon for applications to hard code passwords.

having said that, you might be able to setup a user with no password, but only allow connections via localhost. This might help your embedded password issue but now anyone who can run things locally can get root on the database without a password.
# 6  
Old 12-21-2008
hi bulkbiz,

Actually it is possible to hardcode a password inside shell script and hide it from casual viewers (not advanced viewers).

Either use,

gzexe - compress executable files in place

Find more at "man gzexe". It is just gziping your shell script and creates another shell wrapper to automatically gunzip and execute when somebody calls it. Beware of this if you uncompress this program, it is pretty easy to read the contents. Simply more useful to compress and save disk space.

or

shc - Generic shell script compiler

Download shc for you distribution and install it. This small program first encrypts your shell script using RC4 algorithm and then creates a binary executable file which can decrypt the program into memory at runtime. Go through "man shc" for additional options. The biggest disadvantage of this utility is it stores the encryption key also inside the same binary which allow us to decrypt and read it. Also read this article how to beat shc http://www.linuxjournal.com/article/8256

Last edited by meharo; 12-21-2008 at 06:49 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mysqldump rotate backup

I have a very simple script that uses a cron job to take a daily backup of our orders database. echo "Dumping ORDERS database"; mysqldump -u root --password='mypassword' -h '1.1.1.1' --opt --compress ORDERS $tbl_names > /Volumes/Files_Backup_1/db_backups/orders.sql echo "Copied database to... (2 Replies)
Discussion started by: timgolding
2 Replies

2. UNIX for Dummies Questions & Answers

Mysqldump certain tables

Hi, I have to upload part of my database periodically when i make changes to product data etc. However I only want to upload certain tables. We suffer from bandwidth chock here, so i want to write a couple of separate scripts that upload parts of the database that changed. The database is large... (5 Replies)
Discussion started by: timgolding
5 Replies

3. Shell Programming and Scripting

Logon to multiple hosts using ssh hardcode password

Hi im trying to write a script to logon to list of servers with same userID. I have no option/plan to implement ssh-keygen sharing between the systems, so i have written script creating 2 files, file1 holds list of hosts host1 host2 host3 file2 has following script for i in `cat file1`... (1 Reply)
Discussion started by: dreamaix
1 Replies

4. Shell Programming and Scripting

How can we hardcode TNS_ADMIN?

How can we hardcode TNS_ADMIN? When i try to connect to db with the code below..i get TNS issue. So wpndering if i can hardcode TNS.. <html> <head> <title>xxxxxxxxxxxxxx</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <% ### Load modules, connect to... (2 Replies)
Discussion started by: rdhanek
2 Replies

5. UNIX for Advanced & Expert Users

Change in script to hardcode in a query

HI, In a script i am using a query ${SQLPLUS_SETTINGS} select c.CYCLE_CODE ||'|'|| NEXT_CYCLE_INST ||'|'|| CYCLE_YEAR ||'|'|| to_char(trunc(CYCLE_CLOSE_DATE +1),'DD-MON-YY YY')||'|'|| to_char(ADD_MONTHS(CYCLE_CLOSE_DATE,1),'DD-MON-YYYY') ||'|'|| CYCLE_MONTH FROM PM1_CYCLE_STATE C,... (2 Replies)
Discussion started by: madfox
2 Replies

6. Shell Programming and Scripting

Help needed for mysqldump command

I want to take a backup of a database and redirect the output of the whole process to a log file. I am using the below command: mysqldump -A --add-drop-table > mysql-daily-backup.sql &> /tmp/backup_log/mysql.log Is there anything wrong with the syntax? ---------- Post updated at 08:32 PM... (0 Replies)
Discussion started by: proactiveaditya
0 Replies

7. UNIX for Advanced & Expert Users

mysqldump slowing down the process?

Hi All, I have a data calculation process-a perl script running each and every hour which will do some calculations on the data stored in a mysql server. Normally it tooks around 2minutes (max) to complete. But in case if i did any actions on the linux box where the database is... (7 Replies)
Discussion started by: DILEEP410
7 Replies

8. Shell Programming and Scripting

how to change root password using shell script with standard password

Hi Friends. I am new to scripting now i want to change the root password using the script with standard password. which is the easy scripting to learn for the beginner, Thanks in advance. (2 Replies)
Discussion started by: kurva
2 Replies

9. Solaris

i wanto hardcode password for a username to ssh to a server using script

Dear all i want to ssh to a server via running a shell script with a username and i want to hard code the password for that particular username can u help me please Thank u Naree (8 Replies)
Discussion started by: naree
8 Replies
Login or Register to Ask a Question