Mysql2::错误-访问被拒绝为用户的根@'localhost'(使用密码:是的)

时间:2021-08-08 20:56:42

I am using training software to learn Rails. I am using Windows 7 64bit with Service Pack 1 installed. I have MySQL Server 5.6 installed, along with MySQL Workbench 6.2 CE... if that makes a difference or not.

我正在使用培训软件来学习Rails。我使用的是Windows 7 64位,安装了Service Pack 1。我安装了MySQL Server 5.6,还有MySQL Workbench 6.2 CE…如果这能起到作用的话。

Right, so I building a content management system in the training and I am on "Accessing a Project" in the training software. I was told to start the server, which I did and everything is running fine. However, when visiting the site in Firefox, I received this error:

是的,所以我在培训中建立了一个内容管理系统,我正在培训软件中“访问一个项目”。我被告知要启动服务器,我做了,一切正常。但是,当我访问Firefox的站点时,我收到了这个错误:


Mysql2::Error

Mysql2:错误

Access denied for user 'root'@'localhost' (using password: YES)

用户“根”@“localhost”的访问权限(使用密码:YES)

Rails.root: E:/Programming/Rails/Sites/Simple_CMS Application Trace | Framework Trace | Full Trace

Rails。根:E:/编程/Rails/站点/Simple_CMS应用程序跟踪|框架跟踪|完整跟踪。

mysql2-0.3.18-x64 (mingw32) lib/mysql2/client.rb:70:in connect' mysql2-0.3.18-x64 (mingw32) lib/mysql2/client.rb:70:ininitialize' activerecord (4.2.0) lib/active_record/connection_adapters/mysql2_adapter.rb:18:in new' activerecord (4.2.0) lib/active_record/connection_adapters/mysql2_adapter.rb:18:inmysql2_connection' activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in new_connection' activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:446:incheckout_new_connection' activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in acquire_connection' activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:349:inblock in checkout' C:/Languages/Ruby/21-x64/lib/ruby/2.1.0/monitor.rb:211:in mon_synchronize' activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:348:incheckout' activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in block in connection' C:/Languages/Ruby/21-x64/lib/ruby/2.1.0/monitor.rb:211:inmon_synchronize' activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in connection' activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:565:inretrieve_connection' activerecord (4.2.0) lib/active_record/connection_handling.rb:113:in retrieve_connection' activerecord (4.2.0) lib/active_record/connection_handling.rb:87:inconnection' activerecord (4.2.0) lib/active_record/migration.rb:384:in connection' activerecord (4.2.0) lib/active_record/migration.rb:371:incall' actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in block in call' activesupport (4.2.0) lib/active_support/callbacks.rb:88:incall' activesupport (4.2.0) lib/active_support/callbacks.rb:88:in _run_callbacks' activesupport (4.2.0) lib/active_support/callbacks.rb:734:in_run_call_callbacks' activesupport (4.2.0) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:incall' actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in call' actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:incall' actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' web-console (2.1.1) lib/web_console/middleware.rb:37:incall' actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' railties (4.2.0) lib/rails/rack/logger.rb:38:incall_app' railties (4.2.0) lib/rails/rack/logger.rb:20:in block in call' activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:inblock in tagged' activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in tagged' activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:intagged' railties (4.2.0) lib/rails/rack/logger.rb:20:in call' actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:incall' rack (1.6.0) lib/rack/methodoverride.rb:22:in call' rack (1.6.0) lib/rack/runtime.rb:18:incall' activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in call' rack (1.6.0) lib/rack/lock.rb:17:incall' actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in call' rack (1.6.0) lib/rack/sendfile.rb:113:incall' railties (4.2.0) lib/rails/engine.rb:518:in call' railties (4.2.0) lib/rails/application.rb:164:incall' rack (1.6.0) lib/rack/lock.rb:17:in call' rack (1.6.0) lib/rack/content_length.rb:15:incall' rack (1.6.0) lib/rack/handler/webrick.rb:89:in service' C:/Languages/Ruby/21-x64/lib/ruby/2.1.0/webrick/httpserver.rb:138:inservice' C:/Languages/Ruby/21-x64/lib/ruby/2.1.0/webrick/httpserver.rb:94:in run' C:/Languages/Ruby/21-x64/lib/ruby/2.1.0/webrick/server.rb:295:inblock in start_thread'

mysql2-0.3.18-x64(mingw32)lib / mysql2 /客户端。rb:70:在connect' mysql2-0.3.18-x64 (mingw32) lib/mysql2/客户端。rb:70:ininitialize activerecord(4.2.0)lib / active_record / connection_adapters / mysql2_adapter。rb:18:在new' activerecord (4.2.0) lib/active_record/connection_adapter /mysql2_adapter中。rb:18:inmysql2_connection activerecord(4.2.0)lib / active_record / connection_adapters /文摘/ connection_pool。rb:436:在new_connection' activerecord (4.2.0) lib/active_record/connection_adapter /abstract/connection_pool中。rb:446:incheckout_new_connection activerecord(4.2.0)lib / active_record / connection_adapters /文摘/ connection_pool。rb:422:在acquire_connection' activerecord (4.2.0) lib/active_record/connection_adapter /abstract/connection_pool中。rb:349:整块结帐的C:/语言/ Ruby / 21-x64 / lib / Ruby / 2.1.0 /班长。rb:211:在mon_synchronize' activerecord (4.2.0) lib/active_record/connection_adapter /abstract/connection_pool中。rb:348:incheckout activerecord(4.2.0)lib / active_record / connection_adapters /文摘/ connection_pool。rb:263:in block in connection' C:/ language /Ruby/21-x64/lib/ Ruby/ 2.1.0/monitor。rb:211:inmon_synchronize activerecord(4.2.0)lib / active_record / connection_adapters /文摘/ connection_pool。rb:262:连接“activerecord (4.2.0) lib/active_record/connection_adapter /abstract/connection_pool”。rb:565:inretrieve_connection activerecord(4.2.0)lib / active_record / connection_handling。rb:113:在retrieve_connection' activerecord (4.2.0) lib/active_record/connection_handling中。rb:87:inconnection activerecord(4.2.0)lib / active_record /迁移。rb:384:连接“activerecord (4.2.0) lib/active_record/migration”。rb:371:incall actionpack(4.2.0)lib / action_dispatch /中间件/回调。rb:29:in block in call' activesupport (4.2.0) lib/active_support/回调。rb:88:incall activesupport这样(4.2.0)lib / active_support /回调。rb:88:在_run_callbacks的activesupport (4.2.0) lib/active_support/回调。rb:734:in_run_call_callbacks activesupport这样(4.2.0)lib / active_support /回调。rb:81:在run_callbacks的actionpack (4.2.0) lib/action_dispatch/中间件/回调中。rb:27:incall actionpack(4.2.0)lib / action_dispatch /中间件/复载机。rb:73:in call' actionpack (4.2.0) lib/action_dispatch/中间件/remote_ip。rb:78:incall actionpack(4.2.0)lib / action_dispatch /中间件/ debug_exceptions。rb:17:in call' web console (2.1.1) lib/web_console/中间件。rb:37:incall actionpack(4.2.0)lib / action_dispatch /中间件/ show_exceptions。rb:30:in call' railties (4.2.0) lib/rails/rack/logger。rb:38:incall_app railties(4.2.0)lib / rails /架/记录器。rb:20:in block in call' activesupport (4.2.0) lib/active_support/tagged_logging。rb:68:在标记的activesupport (4.2.0) lib/active_support/tagged_logging中插入。rb:26:在标记' activesupport (4.2.0) lib/active_support/tagged_logging中。rb:68:intagged railties(4.2.0)lib / rails /架/记录器。rb:20:in call' actionpack (4.2.0) lib/action_dispatch/中间件/request_id。rb:21:incall架(1.6.0)lib /架/ methodoverride。rb:22:in call' rack (1.6.0) lib/rack/runtime。rb:18:incall activesupport这样(4.2.0)lib / / local_cache_middleware active_support /缓存策略。rb:28:in call' rack (1.6.0) lib/rack/lock。rb:17:incall actionpack(4.2.0)lib / action_dispatch /中间件/静态的。rb:113:in call' rack (1.6.0) lib/rack/sendfile。rb:113:incall railties(4.2.0)lib /铁路/引擎。rb:518:in call' railties (4.2.0) lib/rails/应用程序。rb:164:incall架(1.6.0)lib /架/锁。rb:17:in call' rack (1.6.0) lib/rack/content_length。rb:15:incall架(1.6.0)lib /架/处理/ webrick。rb:89:在服务“C:/ Ruby / 21-x64 / lib / Ruby /语言/ 2.1.0 / webrick / httpserver。rb:138:在职“C:/ Ruby / 21-x64 / lib / Ruby /语言/ 2.1.0 / webrick / httpserver。rb:94:在运行“C:/ Ruby / 21-x64 / lib / Ruby /语言/ 2.1.0 / webrick /服务器。rb:295:整块start_thread的

Request

请求

GATEWAY_INTERFACE: "CGI/1.1"
HTTP_ACCEPT: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
HTTP_ACCEPT_ENCODING: "gzip, deflate"
HTTP_ACCEPT_LANGUAGE: "en-GB,en;q=0.5"
REMOTE_ADDR: "::1"
REMOTE_HOST: "::1"
SERVER_NAME: "localhost"
SERVER_PROTOCOL: "HTTP/1.1"

Okay, so reading the previous answers, it appears that I have a password error. At first, I couldn't remember the password I assigned so I looked on here for ways to change it. I thought I changed it but apparently I did not. When I added the password to database.yml file, I still get the same error.

好的,读取之前的答案,看起来我有一个密码错误。起初,我不记得我分配的密码,所以我在这里寻找改变它的方法。我想我改了,但显然没有。当我将密码添加到数据库时。yml文件,我还是会犯同样的错误。

Frustrated, I looked at another forum post similar to this one and found I have to use the code:

失望的是,我查看了另一个类似于这个的论坛帖子,发现我必须使用以下代码:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('somepassword')

Well, that isn't working. Maybe I lack the permissions, but I thought root access gave you administrative privileges.

这不是工作。也许我没有权限,但是我认为root权限给了您管理权限。

1 个解决方案

#1


0  

You need to follow the steps Here in order to reset the root password. There are number of steps. If it was me and there is nothing that cannot be redone or recovered from a backup on mysql, I would just reinstall from scratch with a fresh root password that I wont forget.

需要遵循的步骤在这里为了重置根密码。有许多步骤。如果是我,在mysql上的备份中没有任何不能重做或恢复的东西,我只需重新安装一个我不会忘记的新根密码。

#1


0  

You need to follow the steps Here in order to reset the root password. There are number of steps. If it was me and there is nothing that cannot be redone or recovered from a backup on mysql, I would just reinstall from scratch with a fresh root password that I wont forget.

需要遵循的步骤在这里为了重置根密码。有许多步骤。如果是我,在mysql上的备份中没有任何不能重做或恢复的东西,我只需重新安装一个我不会忘记的新根密码。