Mit CPC Mit CPC - 7 months ago 43
MySQL Question

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

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.


Try semicolon instead of comma in command -

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