[英]How to have “mysql” command on Mac OS?
I was given a code repo which requires mysql
in command line. 我得到了一个代码仓库,它在命令行中需要mysql
。
I am using Mac OS 10.11 我使用的是Mac OS 10.11
First, I installed MySQL Community Server
from http://dev.mysql.com/downloads/mysql/ and install it by running the PKG
file. 首先,我从http://dev.mysql.com/downloads/mysql/安装了MySQL Community Server
,并通过运行PKG
文件进行安装。
After that, I opened System Preferences to start MySQL Server. 之后,我打开了系统偏好设置以启动MySQL服务器。
Then, I tried to execute 然后,我试图执行
/usr/local/mysql/bin/mysql -uroot
and there is an error: 并且有一个错误:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
How could I have mysql
in command line? 我怎么能在命令行中使用mysql
?
Thanks, 谢谢,
Typically the command is: 通常命令是:
/usr/local/mysql/bin/mysql -u root -p
which will prompt you for your root password (which might be blank unless you changed it) 这将提示您输入root密码(除非您更改密码,否则可能为空)
You can also use: 您还可以使用:
/usr/local/mysql/bin/mysql -u root -p[password]
but keep in mind that password will be visible onscreen as you are typing it unlike the straight -p
option that will hide your password as you type it when prompted. 但请记住,密码会在屏幕上可见,你不像直键入它-p
为你提示时键入它,将隐藏你的密码选项。
Take a look at the options for mysql: https://dev.mysql.com/doc/refman/5.6/en/mysql-command-options.html 看一下mysql的选项: https : //dev.mysql.com/doc/refman/5.6/en/mysql-command-options.html
In your case, I'd try /usr/local/mysql/bin/mysql -u root -p
then hit enter . 在你的情况下,我尝试/usr/local/mysql/bin/mysql -u root -p
然后点击回车 。 mysql will prompt you for your password - type in in and hit enter again. mysql会提示您输入密码 - 输入并再次输入 。 If it's wrong mysql will let you know and then you'll have to go about resetting the mysql root password. 如果它错了,mysql会让你知道,然后你将不得不重置mysql root密码。
https://coolestguidesontheplanet.com/how-to-change-the-mysql-root-password/ is a reasonable set of instructions for doing that in OS X (may be out of date for your version of MySQL but the comments will help) but YMMV depending on where mysql was installed, etc... https://coolestguidesontheplanet.com/how-to-change-the-mysql-root-password/是在OS X中执行此操作的一组合理说明(对于您的MySQL版本可能已过时,但评论将有所帮助)但YMMV取决于安装mysql的位置等...
Basically those instructions are: 基本上这些说明是:
sudo /usr/local/mysql/support-files/mysql.server stop
sudo mysqld_safe --skip-grant-tables
mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED by 'password';
FLUSH PRIVILEGES;
exit
sudo /usr/local/mysql/support-files/mysql.server start
Which 哪一个
That should allow you to run mysql -u root -p
and use the new password set in #4. 这应该允许你运行mysql -u root -p
并使用#4中设置的新密码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.