views:

42

answers:

1

Hello all,

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  A: 

you need to add the -e parameter

cmd /c mysql -u root -p -e "GRANT ALL ON *.* TO 'newuser'@'localhost' IDENTIFIED BY 'pass'"
David Rabinowitz
It works! Thanks.
Cyril