在 MySQL 上以其他用户身份登录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5690260/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:32:14  来源:igfitidea点击:

Logging in as a different user on MySQL

mysql

提问by Aaron

I created a different user, when I try to log into mysql it will not let me. I think I am missing a step. I am using windows 7. When I log in it automatically asks me for a password. If I enter the root password I can use mysql. If I enter the password I have created for the user, I get an error I cannot read and the program exits. Do I need to first login as root then somehow log in as new user. I am very confused. The code I used to create the new user is here:

我创建了一个不同的用户,当我尝试登录 mysql 时它不会让我。我想我错过了一步。我使用的是 Windows 7。当我登录时,它会自动要求我输入密码。如果我输入 root 密码,我可以使用 mysql。如果我输入我为用户创建的密码,我会收到一个无法读取的错误并且程序退出。我是否需要先以 root 身份登录,然后以新用户身份登录。我很困扰。我用来创建新用户的代码在这里:

Trouble logging into mysql as non root

无法以非 root 用户身份登录 mysql

回答by Zach Rattner

Try this:

尝试这个:

>> mysql -u USERNAME -p 

Press enter, and you'll be prompted for the password for USERNAME.

按 Enter,系统将提示您输入 USERNAME 的密码。

回答by Tom Silverman

There is no mysql equivalent to Oracle's 'connect' statement in the sense that allows to switch a user once already logged in to a mysql console session.

从某种意义上说,没有与 Oracle 的“connect”语句等效的 mysql,它允许在登录到 mysql 控制台会话后切换用户。

回答by dj_segfault

You may have created the new user, but not given that user sufficient permissions on the database you're trying to manage.

您可能已经创建了新用户,但没有为该用户授予您尝试管理的数据库的足够权限。