Centos7
Shell script에서 MySQL Query 사용하는 방법
돌크리트
2019. 5. 15. 11:01
1
|
[root@localhost ~]# mysql -u [mysql사용자명] -p [접속하고자 하는 DB이름] -e "mysql query"
|
example)
1
2
3
4
5
6
7
8
9
|
[hadoop@master ~]$ mysql -u hadoop -p member -e "select * from student"
Enter password:
+----+-------+---------------+
| id | name | phone |
+----+-------+---------------+
| 1 | smith | 010-1111-1111 |
| 2 | kelly | 010-2222-2222 |
+----+-------+---------------+
[hadoop@master ~]$
|
-u : user의 약자
-p : password의 약자
-e : exxcute의 약자