I'm having issue connecting to MySQL and running a SQL query that is located in a directory.
This is what I have in the .sh file:
mysql -h hostname -P 3306 -u username -p password -A -e < /home/testing.sql
It returns an error "option '-e' requires an argument". The SQL file contains a simple create table statement in a schema I have access to.
Thanks in advance for your help!
The option -e
expects a statement that shall be e xecuted, and you specified no such statement. To fix that, remove the -e
option. The -A
stands for disabling auto rehashing, but that option is on by default, so you can remove that as well. Your line should therefore look like this:
mysql -h hostname -P 3306 -u username -p password < /home/testing.sql
这可以工作
mysql -h hostname -P 3306 -u username -p password -A -e "$(cat /home/testing.sql)" your_database
Turns out there should be no space between -p and password. That resolved the issue!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.