全部博文(930)
分类: Mysql/postgreSQL
2010-04-12 17:58:23
shell中如何直接执行mysql语句那....
1.直接管道过去
echo "show databases" | mysql -uroot -p'123456'
Database
information_schema
mysql
sakila
test
2.从文件
[root@kenthy sakila-db]# cat file
show databases;
[root@kenthy sakila-db]# mysql -uroot -p'123456' < file
Database
information_schema
mysql
sakila
test
3.块
[root@kenthy sakila-db]# mysql -uroot -p'123456' << SQL
> show databases;
> SQL
Database
information_schema
mysql
sakila
test