0

I have to execute MySQL command without entering the MySQL prompt any interaction. For this I have to specify password at command-line , such as

mysql -u 'user' -p'password' command;

Though my user which is root is not having password (checked in mysql.user table) I am unable to use it for running the MySQL commands at commandline and not entering prompt.

I have tried using below things:

mysql -u root 'followed by query'
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

mysql -u root -p 'followed by query'

Prompts for password and when I just press enter it goes into prompt.

Please suggest how to execute this without any interaction (Using Enter key).

1
  • you mean you want to execute a query with concating query with this mysql -u root -p? right? Commented Dec 12, 2014 at 7:33

2 Answers 2

1

Query should be specified with -e option so you should try something like this:

mysql -u root -e 'followed by query'
Sign up to request clarification or add additional context in comments.

Comments

0

First of all make sure MySQL user that you are using has access to database that you are trying to connect. To get execute MySQL command with out entering in MySQL prompt Also change your query like below.

mysql --user=mysql_username --password=mysql_password -e "select *  from database.table";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.