MySQL: redirection of the stdout on a file

Hello guys !

Is it possible redirect the standard output of the mysql promp to a text file ?

Thake as example the following statement.

mysql> SELECT * FROM USERS;
Code:
+---------+----------------+---------------+--------------+
| USER_ID | USER_FIRSTNAME | USER_LASTNAME | USER_ADDRESS |
+---------+----------------+---------------+--------------+
|      1  |       John     |     Smith     |   Street 2   |
|      1  |      Carl      |    Peterson   |  Street 25   |
|      1  |        Mary    |  O'Conner     |   Street 5   |
+---------+----------------+---------------+--------------+

3 rows in set (0.00 sec)
Is it possible print on a text file the table USERS called by the SELECT command ?

Thanks in advance.
 
Yes, but the easiest way I've found to do it is, if you were user root, for example and you have a database called clients with a table users
Code:
mysql -uroot -p -e "select * from users" clients > user.list
 
Back
Top