EXCEL CONNECT TO MYSQL RUN QUERY PASSWORD
The password to use when connecting to the server.Ĭonnect to the MySQL server on the given host. The MySQL user name to use when connecting to the server. The most useful MySQL options when executing SQL queries from the Linux command-line or a Bash script: Option Save the output to a file: $ mysql -u USER -p PASSWORD -e " SQL_QUERY" > FILEĬool Tip: Create a MySQL database and GRANT ALL PRIVILEGES on it to a user! Simple and clear MySQL tutorial with good examples! Read more → Suppress table borders: $ mysql -u USER -p PASSWORD -B -e " SQL_QUERY" Suppressing column headings: $ mysql -u USER -p PASSWORD -N -e " SQL_QUERY" Run SQL query on the explicitly specified host: $ mysql -u USER -p PASSWORD -h HOSTNAME -e " SQL_QUERY" Run SQL query on the explicitly specified database: $ mysql -u USER -p PASSWORD -D DATABASE -e " SQL_QUERY" p PASSWORD: This is not a typo! There should not be a space between your password and the -p when you pass it on the command-line!
EXCEL CONNECT TO MYSQL RUN QUERY HOW TO
In this article i will show the most useful, from my point of view, options of the MySQL command-line client and show how to run multiple SQL queries to a database from a Bash script.Ĭool Tip: List MySQL users, their passwords and granted privileges from the command-line prompt! Read more → MySQL: Execute SQL Queries From The Linux ShellĮxecute SQL query from the Linux command-line: $ mysql -u USER -p PASSWORD -e " SQL_QUERY" Sometimes it is needed to run some MySQL queries from the Linux command-line interface without accessing the interactive MySQL prompt.įor example, when it is required to schedule a backup of MySQL database or to automate execution of some SQL queries with a Bash script.