Create mysql database with bash script - confused


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create mysql database with bash script - confused
# 1  
Old 04-17-2010
Create mysql database with bash script - confused

Hi, i have the following:
Code:
db="create database xxx;GRANT ALL PRIVILEGES ON xxx.* TO user@localhost IDENTIFIED BY 'password';FLUSH PRIVILEGES;quit;"
mysql -u root -p$mysql_pass -e "$db"

I don't understand why this is failing, it works fine when run from cmd but when is run in a bash script, mysql is giving me an error, something with incorrect syntax near 'quit'. I'm sure is something simple but I can't figure it out.

Thank you.
# 2  
Old 04-17-2010
Just remove the last 'quit;'. it isn't needed and is redundant when you're executing a script that includes the -e.

Cheers,
Keith
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help on Insert data to phpMyAdmin mySQL database from Shell Script

Sorry to disturb you, I would like to seek help on inserting data whenever the switch is on or off to my phpMyAdmin mySQL database from my Shell Script. I'm using Raspberry PI as my hardware and I have follow this LINK: instructables.com/id/Web-Control-of-Raspberry-Pi-GPIO/?ALLSTEPS to create my... (4 Replies)
Discussion started by: aoiregion
4 Replies

2. Shell Programming and Scripting

Help with script to create users from database query

#!/bin/bash user=`mysql userList -uuserlist -puserlistpassword -s -N -e "SELECT userName FROM users WHERE activated='n'"` for i in $user; do useradd "$i" -m doneThis is what I have done so far. But obviously it still does not work. I'm trying to create users based on information stored in a... (5 Replies)
Discussion started by: bucketuk
5 Replies

3. UNIX and Linux Applications

Really simple shell script to create oracle database

Hello , I am new in this forum and need your help as I am totally confused :confused: I read a lot of threads and tried to search a lot but did not get the exact answer to my question. I just want a simple (content wise may be long) shell script to create oracle database. In detail:... (5 Replies)
Discussion started by: rahoolm
5 Replies

4. Programming

Creating a bash script that create/open database

Hi. I have two text files(tables) which include some information and I want to make some query codes using them. First of all, I want to create bash script that read this two tables, create/open database and insert data from files into database. #!/bin/bash while read line; do ... (1 Reply)
Discussion started by: rlaxodus
1 Replies

5. Programming

Help with mySQL database by perl script

Hello; I was trying to set up a mysql database using following script, but never went through. The code seems fine without any syntax error as I tested it: perl -c Brapa0101-db.pl Brapa0101-db.pl syntax OKHowever, whenever I run it, an error message was tossed out: DBD::mysql::st execute... (7 Replies)
Discussion started by: yifangt
7 Replies

6. Shell Programming and Scripting

How to run bash script from within MySQL

Can someone tell me the syntax to run a shell script from within MySQL? I know there is a way to do it, but I can't remember the syntax. I thought it was something like: mysql> \. /user/myscript; but I get this error: Failed to open file '/user/myscript;', error: 2 Please help!... (4 Replies)
Discussion started by: peterv6
4 Replies

7. Shell Programming and Scripting

shell script to insert data from gps.txt to mysql database

Hi, I have gps receiver, by using gpsd data i can read gps log data to my database(my sql). Steps: 1. telenet localhost 2947 > gps.txt (press enter) 2. r (press enter) //then i will get the data like below in gps.txt file Trying 127.0.0.1... Connected to localhost.... (1 Reply)
Discussion started by: gudivada213
1 Replies

8. Web Development

Confused maybe about MySQL Dump & PHP

Hello. the purpose of my efforts right now are to get a larger script of mine (which the admin told me he'd put into cron for me) to properly back-up my MySQL database. To test out the sql back-up part (before getting the whole script into cron, and having it not work) I wanted to test it. So... (12 Replies)
Discussion started by: jzacsh
12 Replies
Login or Register to Ask a Question