Rails - gem install mysql doesn't work on cygw

2019-04-16 08:01发布

问题:

I tried to do

gem install mysql

but there is an error. "Could not create Makefile due to some reason..."

How do I fix this? I believe I installed mysql on cygwin. Help!!

回答1:

gem install mysql --platform x86-mingw32 works in cygwin



回答2:

  • First, download the MySQL source code - you'll want the same version as whatever MySQL version you already have running (I'm using 5.1.42, which is the current binary from the MySQL Web site, but select whatever you need here: MySQL Snapshots)
  • Second, find a copy of ttydefaults.h and copy it into your /usr/include/sys - this one is fine: ttydefaults.h. When I say grab it and put it in, I mean literally either use wget or type:

vi /usr/include/sys/ttydefaults.h

and paste it in

  • Third, go into your mysql source directory, and type ./configure --without-server --without-readline. Wait until this finishes.
  • Fourth, go into your mysql/libmysql directory, and type make install.
  • Fifth, go into your mysql/include directory and type:

cp mysqld_error.h /usr/local/include/mysql/

  • Next type:

gem install mysql

  • Finally, go into your source directory for ruby, and make sure all items where you want to connect to "localhost" have "host: 127.0.0.1" instead of leaving the host off. If you leave the host blank, or leave it as local host, you will get a /tmp/mysql.sock error.


回答3:

Unfortunately, you may have to recompile MySQL to obtain the necessary library files.



标签: rubygems