简体   繁体   English

当我尝试rake db:create时,Mysql访问被拒绝错误

[英]Mysql access denied error when I try rake db:create

I install mysql for RoR, and I get an access denied error. 我为RoR安装了mysql,我收到了拒绝访问的错误。 I've tried searching on the internet for how to go about fixing this ... but I have no clue on how to proceed right now. 我试过在互联网上搜索如何解决这个问题......但我现在还不知道如何进行。

Basically, I did this: sudo apt-get install mysql-client mysql-server libmysql-ruby1.8 基本上,我这样做: sudo apt-get install mysql-client mysql-server libmysql-ruby1.8

And I did get the password screen. 我确实得到了密码屏幕。 I am sure I picked a password I know, and yet I am getting the following error when I try to run rake db:create: Access denied for user 'root'@'localhost' (using password: YES) 我确信我选择了一个我知道的密码,但是当我尝试运行rake db时,我收到以下错误:create: Access denied for user 'root'@'localhost' (using password: YES)

How can I fix this? 我怎样才能解决这个问题? Thanks! 谢谢!

Are you able to connect to the database using 您是否可以使用连接到数据库

mysql -uroot -p -hlocalhost

or 要么

mysql -uroot -p -h127.0.0.1

if your able to connect using the second but not the first, modify your database.yml file to include Host: 127.0.0.1 and remove the line with Socket . 如果您能够使用第二个而不是第一个连接,请修改您的database.yml文件以包含Host: 127.0.0.1并删除带有Socket的行。

Try following the instructions for resetting the root password from the official MySQL documentation: 请尝试按照官方MySQL文档中的重置root密码的说明进行操作:

Read this - MySQL Root Password Reset Instructions 阅读本文 - MySQL Root密码重置说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM