set up MySQL with MAMP for Ruby - mysql

I'm trying to use Ruby with the MySQL that comes with MAMP, but there is a problem with the headers not being installed (or something like that).
Someone referred me to the tutorial copied below but I can't get it to work. When I put in the first line ./configure... it says no such directory.
1) One question in particular is, it says, "copy the MySQL source file (mysql-5.1.37.tar.gz) to somewhere on your hard drive." I don't know if by installing MAMP I have already done this step or not. If not, then I don't know what to do.
2) I also don't know what it means when it says "untar" the source file and "cd"...If MAMP is installed, has it been untarred already?
3) Also, do would I just open the terminal and start this code, or do I have to go into Mysql?
I wonder if anyone can tell me how to adapt it. Here are 2 other pieces of information about my installation that might be helpful.
a). MySQL is set up on port 8889 on my computer.
b) Also when I enter "which mysql" in the command line, it responds with "/usr/local/mysql/bin/mysql."
Please help if you can. Thanks.
Download the latest MAMP dmg file.
Download the 1.8.2 (or whichever the latest one you could find) components file from this page.
Unzip, mount the dmg, then copy the MySQL source file (mysql-5.1.37.tar.gz) to somewhere on your hard drive.
Untar the MySQL source file, and `cd` to the source file directory.
Compile the library:
$ ./configure --with-unix-socket-path=/Applications/MAMP/tmp/mysql/mysql.sock --without-server --prefix=/Applications/MAMP/Library
$ make -j2
Copy the compiled libraries into MAMP:
$ cp libmysql/.libs/*.dylib /Applications/MAMP/Library/lib/mysql
Copy the MYSQL headers into MAMP:
$ mkdir /Applications/MAMP/Library/include
$ cp -R include /Applications/MAMP/Library/include/mysql
Install the Ruby MySQL Gem, on Snow Leopard:
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
On Leopard:
$ sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
Enjoy!
EDIT # 2009-11-23: If you’re still experiencing problems (perhaps with RVM), try adding “/Applications/MAMP/Library/bin/” to your $PATH in “~/.bash_profile”.

You should probably follow the tutorial in this link. It is updated for MAMP 1.9.5 with mysql2. A couple of changes have been made to the new MAMP version.
http://blog.mirotin.net/?p=35
Furthermore the tar file you need can be found at this link. Download the MAMP_components_1.9.5.dmg file.
http://sourceforge.net/projects/mamp/files/mamp/1.9.5/

Finally got through this with this blog post: http://newfangled.me/installing-mamp-and-rails-on-a-mac/
Here's the archived version of that incase it goes offline http://web.archive.org/web/20130728130916/http://newfangled.me/installing-mamp-and-rails-on-a-mac
The other answer's reference 404s for me. http://blog.mirotin.net/?p=35
I'd been struggling with this for a while myself.

Related

Problem upgrading from mysql 5.7 to 8.0 in a rails app - missing mysql.so files

I upgraded a working Rails app from Mysql 5.7 to 8.0 on my dev machine but it fails to work on a staging/test server setup with the exact same directory structure and env vars.
I'm getting an error "file not found" for /apps/bundle/ruby/2.7.0/gems/mysql2-0.5.4/lib/mysql2/mysql2.so
ldd /apps/bundle/ruby/2.7.0/gems/mysql2-0.5.4/lib/mysql2/mysql2.so shows a file not found (mysql.so.20) (? - I'm not at work so the filenames might be off) that definitely existed and was part of Mysql 5.7.
So the overall question is how to force the mysql2 gem install to relink to the correct new .so files?
There are a lot of moving parts to this, making things a mystery:
installing mysql from a source tarball,
installing in non-standard directories (apps/usr/local/stow/mysql-8.0.16),
using GNU stow to link mysql .so files from the install directory apps/usr/local/stow/mysql-8.0.16 into a common /apps/usr/local/lib directory (the env var LD_LIBRARY_PATH=/apps/usr/local/lib),
vendoring the gems in the bundle on my dev machine using the bundle package --all command so they're part of the git repo.
I've blown away the /apps/bundle directory contents and rerun bundle install thinking that would force a proper linkage of the .so files without success.
Any ideas? TIA!

about mysql installation in a LAMP environment

When I build a LAMP environment in ubuntu-12.10,
first I installed mysql by mysql-5.5.12.tar.gz,but it told me that it can not find configure
file,it was here:
root#tryandchange-QTH6:/usr/local/src# cd mysql-5.5.12
root#tryandchange-QTH6:/usr/local/src/mysql-5.5.12# ./configure --prefix=/usr/local/mysql
bash: ./configure: 没有那个文件或目录(not exists the document or the file)
who can tell me why?Or tell me that a good way to build a LAMP environment,
but not 'apt-get install'.
XAMPP has downloadable Linux binaries, you just download, extract and run /path/to/xampp/xampp start - I'd recommend those as the easiest way to set up a LAMPP stack.
Link to XAMPP for Linux
Obviously by eschewing the use of apt, you are working with the knowledge that your apache/php/mysql will become obsolete and you will have to work to keep them secured and up-to-date.

Mysql does not download properly because of rvm

I originally configured my computer with rails, ruby and rvm. Afterwards, I downloaded mysql, but when I typed in mysql --version, it tells me that it is not installed. My echo path shows
/Users/ming/.rvm/gems/ruby-1.9.2-p180#default/bin:/Users/ming/.rvm/gems/ruby-1.9.2-p180#global/bin:/Users/ming/.rvm/rubies/ruby-1.9.2-p180/bin:/Users/ming/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
I am not sure if it's because I have both .bash_profile (blank) and .profile (export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"). I know that if they both exist, the latter would be ignored and since my .bash_profile is blank, mysql was saved to la-la land. When I copied the export PATH to the .bash_profile, I get an error message that reads:
"[[ -s "/Users/ming/.rvm/scripts/rvm" ]] && source "/Users/ming/.rvm/scripts/rvm" # This loads RVM into a shell session."
I am using:
Snow Leopard
Rails 3
Ruby 1.9.2
RVM
While I love RVM, it's becoming a real hassle so far whenever I download something new.
I read a bunch of stuff about this and it hasn't been helpful. Please help.
Thank you!
I don't know how you installed MySQL (there are a dozen ways to do so)
from source
from binary dmg
from macports
from fink
from brew
My recommandations is to install MySQL through the 'brew' command.
Personally I use .bash_profile along with rvm/brew and so far no issues.
I can't see the MySQL path in your $PATH though and neither the error message.
Try adding this:
PATH="$PATH:/usr/local/mysql/bin"
to your favourite file.

ruby on rails + xampp + mysql (windows 7)

I am trying to use the mysql package included in xampp with ruby on rails on windows 7, but cannot seem to get them to work together.
I have rails 3.0.0 and xampp 1.7.3
rails works with sqlite within xampp just fine, but when attempting to use mysql via "rails new project -d mysql; cd project; bundle install"
I get the following:
Installing mysql2 (0.2.4) with native extensions C:/xampp/Ruby192/lib/ruby/1.9.1
/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Fail
ed to build gem native extension. (Gem::Installer::ExtensionBuildError)
C:/xampp/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Am I missing anything? All the posts about this issue tell me to use gem install mysql -- --with-mysql-config=PATH, but this does not seem to work with Windows, as I get the same error regardless.
And if it's just not possible, are there any drawbacks to using sqlite now, then trying to migrate the databse over to mysql (or another more robust database) later?
Did you install the mysql gem?
gem install mysql
After this you need to go to the mysql\bin directory in your XAMPP folder and copy the
libmysql.dll
into your ruby\bin folder.
Give it a try and let me know if it works. Also if your MySql version is 5.1 you may need to download a 5.0 version of the same dll.
gem install mysql --no-rdoc --no-ri -- '--with-mysql-lib="D:\xampp\mysql\lib" --with-mysql-include="D:\xampp\mysql\include"'
I used this code for my solution of mysql this is the right way you can USE mysql for xampp.
I once had a similar issue. The important things i noted was that i already have mysql installed for usage via xampp. Firstly, you should make sure that the mysql installation is accessible from cmd by typing
mysql --version
If it gives you a reply of our installation then you're good to go to the next step else copy the mysql bin directory and save it in your user environment variable called PATH. This should allow you to run the cmd code above fruitfully.
Next Step: run (on cmd)
gem install mysql2 --no-rdoc --no-ri
This worked for me.

Rails Error - No Such File to Load -- mysql

I've been fighting with a Rails install on my Mac for some time. The error I'm getting (in my development log) says:
Status: 500 Internal Server Error no such file to load -- mysql
Here's some info:
I can successfully rake db:migrate my application.
I've installed the MySQL gem and it appears in the gem list: mysql (2.8.1).
I have Passenger installed.
The error comes from an existing rails app that works on our production server.
Creating a new Rails app, a new MySQL db (using mysqladmin -uroot create sampledb) works fine.
I've googled this and can't find anything specific to this error. There are a few related results where the solutions relate to paths when installing the MySQL gem. For example,
sudo env ARCHFLAGS="-arch i386" gem install mysql -- \
--with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
--with-mysql-include=/usr/local/mysql/include
Has anyone else experienced this issue or suggest a solution?
Thanks for the response - the good news is, the problem is solved.
The bad news - I'm not entirely sure what fixed it. I can tell you this: it had something to do with the mysql gem install and all the flags pointing to lib, include and config. There are probably a dozen different versions of the same command floating around out there for Mac OS X Leopard.
The odd thing was that ruby appeared to be connected to mysql on some level (it's ability to rake db for example) but broke when actually loading a page.
The gem install string that ended up working was this:
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
I'd love some clarification on the how's & why's of this. This worked for me, but doesn't include pointers to the app directory, the lib directory or the include directory.
Do you have multiple ruby installed? Try invoking this command to find out: whereis ruby
Which ruby version is you passenger using? You can check this from your apache or nginx configuration
Is the ruby version passenger is using the same as ruby you are using from the command line?
Is mysql gem installed on that ruby version?
Double check if the mysql bin path is in your $PATH system environment variable. If you execute
*echo $PATH*
there must be displayed something like
*/usr/local/mysql/bin*
You can also type
mysql and then the tab-key twice.
If if this doesn't bring up a list of mysql commands (like mysqladmin etc.) the mysql bin path is not set ccorrectly. You can set it by adding the correct directory to your bash profile file.
echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile
Please verify up front if
*/usr/local/mysql/bin*
really contains the mysql commands on your Mac. Important: close and reopen the terminal window to make changes work.