Skip to content
Advertisement

Unable to direct insert in mysql database from linux xshell

i have run below command to insert data into my mysql database. sql query is ok. but after run the query, a prompt is coming to enter the password. but in my database no password is set. SO if i press enter key without writing anything then it is inserting data. How can i avoid to this prompt. That means i want that command will be directly working. No prompt will come for Enter Password.

Enter password: 
linux-pott:/opt/lampp/htdocs # mysql -uroot -p  -e 'insert into dialer_rate(date_time,time,mno,trx_type,trx_result,trx_value) values("2015-02-19","12:14","air","N/A","Not_Running",0) ' bkash
Enter password: 
linux-pott:/opt/lampp/htdocs # 

Advertisement

Answer

remove the option -p in your cmd:

linux-pott:/opt/lampp/htdocs # mysql -u root -e 'insert into dialer_rate(date_time,time,mno,trx_type,trx_result,trx_value) values("2015-02-19","12:14","air","N/A","Not_Running",0) ' bkash

From the official documentation:

For a long option that takes a value, separate the option name and the value by an “=” sign. For a short option that takes a value, the option value can immediately follow the option letter, or there can be a space between: -hlocalhost and -h localhost are equivalent. An exception to this rule is the option for specifying your MySQL password. This option can be given in long form as –password=pass_val or as –password. In the latter case (with no password value given), the program prompts you for the password. The password option also may be given in short form as -ppass_val or as -p. However, for the short form, if the password value is given, it must follow the option letter with no intervening space. The reason for this is that if a space follows the option letter, the program has no way to tell whether a following argument is supposed to be the password value or some other kind of argument. Consequently, the following two commands have two completely different meanings:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement