不進入MySQL,怎樣運行sql 語句?
使用--execute(-e)選項:
mysql -u root -p -e "SELECT User, Host FROM User" MySQL
可以按這種方式傳遞多個SQL 語句,用分號隔開:
shell> MySQL -u root -p -e "SELECT Name FROM Country WHERE Name LIKE
'AU%';SELECT COUNT(*) FROM City" world
Enter passWord: ******
+-----------+
| Name |
+-----------+
| Australia |
| Austria |
+-----------+
+----------+
| COUNT(*) |
+----------+
| 4079 |
+----------+
請注意長形式(--execute)後面必須緊跟一個等號(=)。