[英]How to switch to new user from MySQL console
Im having a little problem in using mysql on windows. 我在Windows上使用mysql有一个小问题。 I know how to create a new user and giving grants to the new user and all. 我知道如何创建新用户以及如何向新用户和所有人授予资金。 But i don't know how to switch to new user from mysql console! 但是我不知道如何从mysql控制台切换到新用户!
You have to exit and log in again using the new username. 您必须退出并使用新用户名再次登录。
From shell: 从外壳:
mysql --user=user_name --password=your_password db_name
Reference: 参考:
Once you have your new user created, try changing your default shortcut to log in as that user directly instead. 创建新用户后,请尝试更改默认快捷方式,以直接以该用户身份登录。
Go to Start Menu > MySql xx Command Line Client > right-clicked > Properties > Target and changed the user (from -uroot
) to -uyournewuser
: 转到开始菜单> MySql xx命令行客户端>右键单击>属性>目标,并将用户(从-uroot
)更改为-uyournewuser
:
"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql.exe" "--defaults-file=C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" "-uroot" "-p"
When we open MySQL through MySQL console of WampServer it directly logs in as root. 当我们通过WampServer的MySQL控制台打开MySQL时,它将直接以root用户身份登录。 So what I did was I logged in through command prompt and it worked. 所以我所做的就是我通过命令提示符登录并成功了。 E:\\InstalledFiles\\MySql\\bin\\mysql\\mysql5.5.24\\bin
This is where my mysql.exe
file is. E:\\InstalledFiles\\MySql\\bin\\mysql\\mysql5.5.24\\bin
这是我的mysql.exe
文件所在的位置。 So I went till bin and gave this command in the command prompt mysql -u root -p
. 所以我一直到bin并在命令提示符mysql -u root -p
给出了此命令。 So I could login as root from command prompt. 因此,我可以从命令提示符下以root用户身份登录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.