3
votes
1answer
22 views

How do I parse a string in bash into variables using a tab as the delimiter and preserve spaces?

I am in the process of writing a bash script to display various statistics, some of which come from a MySQL database. The pertinant code I'm having difficulty with is: read min max rows <<< ...
3
votes
2answers
51 views

How to make Cron run

I am trying to set up cron to run the mysqlauditgrep command (its the MySQL 5.6 Utilities package). The mysqlauditgrep command is in bash. The command I am looking to run is: mysqlauditgrep ...
1
vote
1answer
33 views

How to set up Cron to run mysqlauditgrep command for 11AM on Friday

I am trying to set up cron to run the mysqlauditgrep command (its the MySQL 5.6 Utilities package). The mysqlauditgrep command is in bash. The command I am looking to run is: mysqlauditgrep ...
0
votes
1answer
140 views

Creating MySQL database and user without password

I am building a set of bash scripts which basically prepare apache virtual hosts, git repositories and other stuff on a cloud server. So far so good, everything is working, but a big problem occurred: ...
3
votes
5answers
614 views

bash restart mysql when it gone run well in SSH part, but not in cronjob

My system is centos 6.5, I write a simple bash shell to check if mysql is crashed, restart service again. I put it in /home/myspace/mysql.sh chown root:root /home/myspace/mysql.sh then run every ...
0
votes
1answer
90 views

Automatic login for mysql used in CGI script

I have written a CGI script using bash which executes a MySQL query. For MySQL authentication , automatic login is used by supplying the credentials in .my.cnf file as shown below . # the following ...
2
votes
1answer
92 views

How do I avoid echoing password (two simultaneous prompts)?

The command I'm talking about is this: mysqldump -u root -p DB | mysql -u root -p DB2 And here's the output: Enter password: Enter password: MYPASS As far as I can tell, after I enter first ...
3
votes
2answers
3k views

Mysql query resultset in bash script

I am using the bash script to connect to the mysql database and execute a query. I use the below script to connect to the database and execute the query. #!/bin/bash Total_Results=$(mysql -h ...
1
vote
1answer
113 views

mysql database dump script adding fuctionality to skip dumped database

I'm using the following script to dump my database. it works great. I want to add functionality that it first checks if a database table is already dumped or not, if a dump exists then it should be ...
0
votes
2answers
851 views

Run mysqld_safe in background

I have a bash script that installs mysql for me. One line, that executes mysqld_safe, makes the script to hang - it won't continue to the following code. Obviously there's ampersand at line's end, ...
0
votes
3answers
716 views

How to create an interactive bash script to collect arguments for a command in linux?

I'm trying to create an interactive bash script where I can collect user input variables to be used as arguments in another command. Can someone provide me an example of this? Currently i want to do: ...
3
votes
1answer
832 views

Convert mysql count(*) to int in bash?

I'd like to execute this and check if count is 0, 1 or > 1 in bash. mysql -e "select count(*) from mydb.mydb;" The output is: +----------+ | count(*) | +----------+ | 0 | +----------+ I ...
4
votes
4answers
5k views

How can I check if mysql is installed using a bash script?

I need to check if mysql is installed from within a bash script. What would be an efficient way of doing that? I thought I could do this: if [ ! -f `which mysql` ] ; then echo "foo" fi But I ...
6
votes
2answers
2k views

Get a progress indicator when importing MySQL databases

I often import MySQL databases, and this can take a while. There is no progress indicator whatsoever. Can one be shown, somehow? Either records imported, MB imported, or tables imported... anything is ...
1
vote
2answers
503 views

Script that uses MySQL query to automatically remove output

I have this query that outputs updates older than 7 days from a database. How would I make a script that takes the MySQL statement and puts it into a script to be executed by cron. echo "select name, ...
2
votes
2answers
216 views

List files that occur lexically after/greater than a given prefix (or, run database upgrade scripts in a proper order)

I'm trying to create a shell script that runs through a bunch of SQL scripts. I've these files: $ ls upgrade/ 01-foo.sql 02-bar.sql 02-baz.sql 03-foo1.sql 04-buz.sql And I've got the version of ...