I have mysql and apache running through XAMPP on my Mac machine (10.6.4). I usually do PHP development with this setup but
now I want to start out with Ruby on Rails.
Unfortunately I cannot get mysql to work with RoR. I start the mysql Server with XAMPP and when I do "rake db:migrate" I get this output:
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
no such file to load -- mysql
mysql is located in /Applications/XAMPP/xamppfiles/bin and the mysql SOCKET is in /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
Therefore my database.yml file looks like this:
development:
adapter: mysql
database: dbname
username: dbuser
password: dbpw
socket: /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
I don't think I need to do a "gem install mysql" because mysql is already running with XAMPP. Anyhow I tried but it failed also:
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
Ruby on Rails uses SQLite as its database by default, but it also supports the use of MySQL.
Rails defaults to using a SQLite database when creating a new project, but you can always change it later.
You need to tell the gem installer the path to your mysql files installed with XAMPP
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-dir=/Applications/XAMPP/xamppfiles/lib/mysql --with-mysql-lib=/Applications/XAMPP/xamppfiles/lib/mysql/ --with-mysql-include=/Applications/XAMPP/xamppfiles/include/mysql/
Also add the correct socket to your database.yml:
development:
adapter: mysql2
encoding: utf8
database: your_db
pool: 5
username: root
password:
socket: /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
After that, run bundle
in the rails project again and it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With