2

During the installation I need to create new MySQL user, new database and populate it from dump file. My question is how can I do it from command line (cmd, Windows)? I mean, I'm calling for cmd from some script, which can start mysql command line client with root privileges but I cannot pass parameters to mysql form outside.

E.g. to create new user I'd like to run something like this:

cmd /c mysql -u root -p GRANT ALL ON *.* TO 'newuser'@'localhost' IDENTIFIED BY 'pass';

Is it possible? To pass *"GRANT ALL ON . TO 'newuser'@'localhost' IDENTIFIED BY 'pass';"* as parameter to mysql?

I hope I've made myself clear. Thanks in advance.

1 Answer 1

1

you need to add the -e parameter

cmd /c mysql -u root -p -e "GRANT ALL ON *.* TO 'newuser'@'localhost' IDENTIFIED BY 'pass'"
Sign up to request clarification or add additional context in comments.

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.