问题描述
我是Ruby on Rails的新手。
我在Windows 10中安装了带devkit和mySQL 5.7的Ruby 2.6.6。 当我尝试在Windows 10中运行一个项目时出现以下错误 无法加载“ active_record / connection_adapters / mysql2_adapter”。确保config / database.yml中的适配器有效。如果您使用的适配器不是“ mysql”,“ mysql2”,“ postgresql”或“ sqlite3”,则将必要的适配器gem添加到Gemfile中。 (LoadError)。
我已经通过以下命令安装了gem mySQL2 gem install mysql2-'--with-mysql-lib =“ C:\ Program Files \ MySQL \ MySQL Connector C 6.1 \ lib” --with-mysql-include =“ C:\ Program Files \ MySQL \ MySQL Connector MySQL C 6.1 \ include“'
我还通过 gem install activerecord-mysql2-adapter 命令安装了适配器
我的gemfile包含以下数据
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails',github: 'rails/rails'
gem 'rails','4.2.8'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
#Use mysql as the database for Active Record
gem 'mysql2','~> 0.4.4'
#0.3.21'
gem 'activerecord-mysql2-adapter'
#gem 'pg','~> 0.15'
# Use SCSS for stylesheets
gem 'sass-rails','~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier','>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails','~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyracer',platforms: :ruby
,我的Ruby gem文件夹中有source 我还从C:\ Program Files \ MySQL \ MySQL Connector C 6.1 \ lib \文件复制libmysql.dll,并将其粘贴到C:\ Ruby26-x64 \ bin文件夹中。
我的项目配置文件夹中也有database.yml文件,其中包含以下详细信息
development:
adapter: mysql2
encoding: utf8
database: dbname
username: root
password: $$$$$
host: localhost
port: 3306
请让我知道如何运行我的应用程序。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)