gpt4 book ai didi

mysql - rails 应用程序在网络浏览器中显示访问被拒绝

转载 作者:行者123 更新时间:2023-11-29 02:32:40 25 4
gpt4 key购买 nike

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

我设置了一个 mysql 没有密码的新环境,以及我是如何收到此错误的。我在哪里更改

'root'@'localhost' (using password: YES)

我的 database.yml 显示在下面我的数据库是 sample_app

# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: mysql2
database: db/development.mysql2
pool: 5
timeout: 5000
database: sample_app
username: root
socket: /tmp/mysql.sock

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
database: db/test.mysql2
pool: 5
timeout: 5000
database: sample_app
username: root
socket: /tmp/mysql.sock

production:
adapter: mysql2
database: db/production.mysql2
pool: 5
timeout: 5000
database: sample_app
username: root
socket: /var/run/mysqld/mysqld.sock

最佳答案

您不应该使用 root 连接到带有应用程序的数据库。创建一个新的用户/密码,其名称可识别它正用于特定的应用程序\任务,然后使用该名称代替 root。

为空密码添加这个 password:

production:
adapter: mysql2
database: db/production.mysql2
pool: 5
timeout: 5000
database: sample_app
username: root
password:
socket: /var/run/mysqld/mysqld.sock

如果您仍然拒绝访问,则数据库表示用户\密码无效

关于mysql - rails 应用程序在网络浏览器中显示访问被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10588344/

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