Skip to main content

MySQL | mysql cli

An optional way to connect into MySQL is using the mysql client. It's possible to create a interactive session or execute one-off commands.

Connection Configuration​

NameTypeDescription
HOSTenv-varThe IP or Host of the MySQL server
PORTenv-varThe port of the MySQL server
USERenv-varThe user to connect in the MySQL server
MYSQL_PWDenv-varThe password to connect in the MySQL server
DBenv-varThe name of the database to connect into

Connection Command​

mysql -h$HOST -u$USER --port=$PORT -D$DB
NOTE

The MYSQL_PWD is mapped as an environment variable, thus there's no need to use it in the command.

How to Use​

Start an interactive session with mysql client

hoop connect mysql

In the same connection, one-off process can be run as well

hoop exec mysql <<EOF
SELECT SLEEP(2);
SELECT NOW();
EOF
hoop exec mysql -f /tmp/myquery.sql
hoop exec psql -i 'SELECT NOW()'