如何传递参数给mysql [英] How to pass parameters to mysql

查看:697
本文介绍了如何传递参数给mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装期间,我需要创建新的MySQL用户,新的数据库,并从转储文件填充它。我的问题是如何从命令行(cmd,Windows)?我的意思是,我从一些脚本调用cmd,它可以启动mysql命令行客户端具有root权限,但我不能将参数传递给mysql形式以外。

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';

有可能吗?要传递*GRANT ALL ON 以'newuser'@'localhost'IDENTIFIED BY'pass';*作为mysql的参数?

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.

推荐答案

您需要添加-e参数

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

这篇关于如何传递参数给mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆