Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to execute mysql command

Status
Not open for further replies.

dagoat10

Programmer
Jun 3, 2010
74
US
I have been trying and trying and trying, i have no idea was is wrong.

I wrote this script to grant a privilege on a table in a mysql database and it keeps saying no grant defined for user test1 at host localhost

Code:
#! /bin/bash

mysql -u root -p <<EOFMYSQL
use mysql
Grant create on Fantasy_Football_2010.* to test1@localhost;
show grants for test1@localhost;
EOFMYSQL

and the user does exist, so why is this happening to me?

 
is there anything i can do or should i come up with an alternative
 
Perhaps there should be a semicolon after
Code:
use mysql
I would guess that mysql would treat
Code:
use mysql
Grant create on Fantasy_Football_2010.* to test1@localhost;
as one command and obviously fail.
Perhaps your code should look like
Code:
#! /bin/bash

mysql -u root -p <<EOFMYSQL
use mysql[b];[/b]
Grant create on Fantasy_Football_2010.* to test1@localhost;
show grants for test1@localhost;
EOFMYSQL
But I'm only guessing :)

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top