Linux中Shell操作MySQL并导出文本文件

[root@kevin bin]# ./MySQL -u root -p111111 -e "use mysql;select host,user,password from user"; 
+-----------+------+-------------------------------------------+
| host      | user | password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *FD571203974BA9AFE270FE62151AE967ECA5E0AA |
| kevin.com | root |                                           |
| 127.0.0.1 | root |                                           |
| localhost |      |                                           |
| kevin.com |      |                                           |
+-----------+------+-------------------------------------------+

****************************************


#!/bin/bash

/usr/local/mysql-5.1.32/bin/mysql -u root -p111111 -e "use mysql;select host,user,password from user"; 

exit 0;

****************************************

如果需要导出mysql的记录到文本文件:

/usr/local/mysql-5.1.32/bin/mysql -u root -p111111 -e "use mysql;select host,user,password from user into outfile '/home/mysql/aa.txt';"

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwpfxj.html