gpt4 book ai didi

mysql - Rails 服务器未在端口 3000 "TCPServer Error: Permission denied - bind (2)"上启动

转载 作者:行者123 更新时间:2023-11-30 23:02:44 25 4
gpt4 key购买 nike

我在 Windows 7 计算机上安装了 Ruby on Rails、MySQL Server 5.6 和 mysql2 gem。 MySQL Server 5.6 在端口 3000 上运行。我的 database.yml 文件是:

# MySQL2
# gem install mysql2
# Ensure the mysql2 gem is defined in your Gemfile
# gem 'mysql2'
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: demo1_development
pool: 5
username: root
password: root
host: 127.0.0.1
port: 3000

# 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
encoding: utf8
reconnect: false
database: demo1_test
pool: 5
username: root
password: root
host: 127.0.0.1
port: 3000

production:
adapter: mysql2
encoding: utf8
reconnect: false
database: demo1
pool: 5
username: root
password: root
host: 127.0.0.1
port: 3000

我使用以下 Gemfile 运行“捆绑安装”:

source 'http://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'

# Use mysql2 as the database for Active Record
gem 'mysql2'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

gem 'devise'

gem 'protected_attributes'

gem 'terminator'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

我可以毫无问题地运行“bundle install”、“rake db:create”和“rake db:migrate”命令。我启动了 MySQL 服务器并在命令行中输入“rails s”。结果如下:警告 TCPServer 错误:权限被拒绝 - 绑定(bind) (2)退出

我确保在 Windows 防火墙中打开端口 3000,并允许 Rails 通过防火墙进行通信。

键入“rails s -p 80”可以工作,Web 应用程序可以在 localhost:80 上工作,但是这些字段将无法工作,因为 MySQL 服务器不会在端口 80 上运行。

我错过了什么吗?如何让 Rails 服务器和 Web 应用程序正常工作?

最佳答案

看起来您正在尝试在端口 3000 上同时运行数据库和 Rails Web 服务器。

编辑:为了澄清,您应该在端口 3000(默认)运行 rails 服务器,并在不同的端口运行 mysql。

无论您在哪个端口上运行 mysql,将该端口放在“端口:”下的 database.yml 设置中。

关于mysql - Rails 服务器未在端口 3000 "TCPServer Error: Permission denied - bind (2)"上启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23271341/

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