I cant find the command in bash that open the connection to mysql and then I could enter user and password and send query.
In Perl its something like this:
use DBI;
$myConnection = DBI->connect("DBI:mysql:DBNAME:localhost", "USERNAME", "PASSWORD");
Maybe someone can advise?
I think you need something like that.
query="example"
mysql -u username -p password mysql -e "$query";
Src: MySql documentation.
Hope have been helpful.
Or you could use a hereoc :
mysql -u username -p password mysql <<-EOF
query1;
query2;
.
.
EOF
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.