gpt4 book ai didi

mysql 不支持 Ruby on Rails

转载 作者:行者123 更新时间:2023-11-29 12:14:21 25 4
gpt4 key购买 nike

您好,我是 Ruby on Rails 新手。我使用 Aptana Studio 创建了一个新项目,并使用 rails server 命令启动服务器。但是当我尝试通过浏览器访问服务器时,出现以下错误。

http://i.stack.imgur.com/7P0FE.png

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


socket = socket.to_s unless socket.nil?

connect user, pass, host, port, database, socket, flags
end

def self.default_query_options

Rails.root:/home/tapas/RubyWorkspace/myproj

Application Trace | Framework Trace | Full Trace
mysql2 (0.3.18) lib/mysql2/client.rb:70:in `connect'
mysql2 (0.3.18) lib/mysql2/client.rb:70:in `initialize'
activerecord (4.2.1) lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
activerecord (4.2.1) lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `mysql2_connection'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/home/tapas/.rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/home/tapas/.rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:567:in `retrieve_connection'
activerecord (4.2.1) lib/active_record/connection_handling.rb:113:in `retrieve_connection'
activerecord (4.2.1) lib/active_record/connection_handling.rb:87:in `connection'
activerecord (4.2.1) lib/active_record/migration.rb:384:in `connection'
activerecord (4.2.1) lib/active_record/migration.rb:371:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.1) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:776:in `_run_call_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'

我尝试使用所有主机:端口组合,例如3000,3306..等,但没有任何效果。这是我的 database.yml 文件的样子。

http://i.stack.imgur.com/a9ok1.png

development:
adapter: mysql2
encoding: utf8
reconnect: false
database: mysql_dev
pool:5
username: root
password: tapaskumar
socket: /var/run/mysqld/mysqld.sock
host: localhost
port: 3306

test:
adapter: mysql2
encoding: utf8
reconnect: false
database: mysql_test
pool: 5
username: root
password: tapaskumar
socket: /var/run/mysqld/mysqld.sock
host: localhost
port: 3306

production:
adapter: mysql2
encoding: utf8
reconnect: false
database: mysql2_prod
pool: 5
username: root
password: tapaskumar
socket: /var/run/mysqld/mysqld.sock
host: localhost
port: 3306

当我尝试从终端访问 mysql 时,它工作正常。我还使用这个命令安装了mysql。

sudo apt-get install mysql-server mysql-client libmysqlclient-dev

并且还为该项目安装了 mysql gem。我无法弄清楚出了什么问题。

最佳答案

我之前正在编辑一些全局database.yml文件。然后我在项目目录的config文件夹中找到了一个特定的database.yml文件,我认为该文件特定于该项目。在几次缩进错误之后,终于得到了它。

关于mysql 不支持 Ruby on Rails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30086208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com