Mit CPC
Mit CPC

Reputation: 11

Need to connect database mysql from shell script (linux centos7)

#!/bin/bash
date +'%F %T'
echo "Show Database"
mysql -u [user] -p[password] -e 'SHOW DATABASES,USE eventime,SELECT * FROM dt;'

output :

2016-09-22 16:01:33
Show Database
Warning: Using a password on the command line interface can be insecure.
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USE eventime,SELECT * FROM dt' at line 1

I don't know why not select data need to connect and select data and delete data eveytime 90 day ago thx for help.

Upvotes: 0

Views: 134

Answers (1)

Nishant Kumar
Nishant Kumar

Reputation: 2169

Try semicolon instead of comma in command -

mysql -u [user] -p[password] -e  'SHOW DATABASES;USE eventime;SELECT * FROM dt;' 

Upvotes: 2

Related Questions