Hello,
How do I execute a SQL query directly from shell command line?
Thanks,
Solved: How to execute a SQL query from shell
Solved: How to execute a SQL query from shell
Last edited by mister_v on Wed Aug 22, 2012 3:18 pm, edited 1 time in total.
Re: How to execute a SQL query from shell
The easiest way I know is with the SQL-command.
If you want juts the data:
-s : separates the values with only tabs
N : skips the column names
-p the password (without spaces, not even between the -p and the password )
else use --password='password.'
Code: Select all
mysql -u user -p -e 'SELECT data FROM table;' database
Code: Select all
mysql -u user -p'password' -sNe 'SELECT data FROM table;' database
N : skips the column names
-p the password (without spaces, not even between the -p and the password )
else use --password='password.'