[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';"