mySQL setup - I'm losing it here.

Newbie here (who else.) I feel confident I can excel in the actual programming of rails apps. But all the tutorials just glaze over mySQL which seems to me, by far, the most problematic area for new users.

I have tried a ton of different things here. I know mySQL is installed and running in one place or another. I don't know how to tell my rails app with the hell to do about it. I do have the "Welcome Aboard" screen showing at localhost:3000 with the following details:

    Ruby version 1.8.6 (i686-darwin8.9.1)     RubyGems version 0.9.2     Rails version 1.2.3     Active Record version 1.15.3     Action Pack version 1.13.3     Action Web Service version 1.2.3     Action Mailer version 1.3.3     Active Support version 1.4.2     Application root /Users/rmorourk/Sites/depot     Environment development     Database adapter mysql

When I try to do something with the database here is what I run into.

    bio4054059:depot rmorourk$ rake db:migrate     (in /Users/rmorourk/Sites/depot)     rake aborted!     Unknown database 'depot_development'

The development portion of my database.yml file looks like this:

    development:       adapter: mysql       database: depot_development       username: root       password: root       host: localhost       socket: /Applications/MAMP/tmp/mysql/mysql.sock

I added the socket line after I installed MAMP as per a tutorial... But when I am in the terminal and I want to do something with the database, like;

    bio4054059:depot rmorourk$ mysql -uroot depot_development     -bash: mysql: command not found

I get the error on the second line --- any advise? I assume this has to be a issue of im not telling something to look in the right somewhere, but I am about ready to put my fist in the wall on this thing. I would LOVE some advise!

Thanks!!

Hello Ryan,

              Make sure you have only one mysql in ur machine and there is database with name 'depot_development' and try again.

Thanks, Sadeesh.

Hello Ryan,

bio4054059:depot rmorourk$ mysql \-uroot depot\_development
\-bash: mysql: command not found

"command not found" is your shell telling you that whatever directory you have installed mysql in to is not on your search path.

If you type "print $PATH" you will see a colon separated ordered list of directories that are searched for executable commands. To temporarily extend the list just type: set PATH=MYSQLHOME:$PATH where MYSQLHOME is the full path to the directory containing mysql executable. i.e. MSQLHOME might be /usr/local/mysql/bin. You should then be able to execute the mysql -uroot... command.

Once you have success with this, you should modify your shell startup file to make the PATH change permanent. Depending on what shell you use this could be .profile, .cshrc, .tshrc, ...

Rick

I have tried a ton of different things here. I know mySQL is installed and running in one place or another. I don't know how to tell my rails app with the hell to do about it. I When I try to do something with the database here is what I run into.

   bio4054059:depot rmorourk$ rake db:migrate    (in /Users/rmorourk/Sites/depot)    rake aborted!    Unknown database 'depot_development'

So you haven't created that database yet. No mystery there. :slight_smile:

when I am in the terminal and I want to do something with the database, like;

   bio4054059:depot rmorourk$ mysql -uroot depot_development    -bash: mysql: command not found

Which simply means MySQL isn't in your PATH. You need to find where the MySQL executables are installed and add that directory to your path. Or create symlinks to, say, /usr/local/bin.

This is just basic *nix stuff.

HTH,

Rick wrote:

Hello Ryan,

� � bio4054059:depot rmorourk$ mysql -uroot depot_development � � -bash: mysql: command not found

"command not found" is your shell telling you that whatever directory you have installed mysql in to is not on your search path.

If you type "print $PATH" you will see a colon separated ordered list of directories that are searched for executable commands. To temporarily extend the list just type: set PATH=MYSQLHOME:$PATH where MYSQLHOME is the full path to the directory containing mysql executable. i.e. MSQLHOME might be /usr/local/mysql/bin. You should then be able to execute the mysql -uroot... command.

Once you have success with this, you should modify your shell startup file to make the PATH change permanent. Depending on what shell you use this could be .profile, .cshrc, .tshrc, ...

Rick

Thanks, here is what I tried:

bio4054059:~ rmorourk$ print $PATH -bash: print: command not found bio4054059:~ rmorourk$ set PATH=/Applications/MAMP/tmp/mysql/:$PATH bio4054059:~ rmorourk$ mysql -uroot -bash: mysql: command not found

Any ideas? I'm using the default terminal on MAC OS X..

Which simply means MySQL isn't in your PATH. You need to find where the MySQL executables are installed and add that directory to your path. Or create symlinks to, say, /usr/local/bin.

First, how do I add it to my PATH? Second, I used this to install mySQL: http://www.mamp.info/en/index.php

Not sure if that was necessary/proper.

The install folder for MAMP has this: /Applications/MAMP/tmp/mysql/

Which holds two files mysql.pid and mysqp.sock - am I correct in assuming that those are the executables I need to set my path too?

Symlinks?

Thanks for the help thus far!

How did you install mysql?

If you used port then its mysql5 not mysql which is the command to open the mysql client...

If you are trying to install mysql using anything other than macports.. dont't... I recommend that you go to macports.org site and download the latest version...

First, how do I add it to my PATH? Second, I used this to install mySQL: http://www.mamp.info/en/index.php

Not sure if that was necessary/proper.

Definitely not necessary, but whatever -- let's assume it worked for the moment :slight_smile:

The install folder for MAMP has this: /Applications/MAMP/tmp/mysql/

Which holds two files mysql.pid and mysqp.sock - am I correct in assuming that those are the executables I need to set my path too?

No. The first contains the process id of the mysql server, and the other is the socket used to communicate with it.

I'd imagine that somewhere under /Applications/MAMP is a directory with a bunch of files with names starting with mysql. Look around, or run this from a prompt:

find /Application/MAMP -type f -name 'mysql*' -print

Symlinks?

Um, I'd recommend doing a little reading up on general *nix/shell use. ("symlinks" is short for "symbolic links" -- a way to have a file referenced from a different directory than it's really located in.) But we can skip that for now; you just need to find what to add to your PATH. And Rick already explained that.

Oh, yeah, but it's `echo $PATH`, not `print`.

HTH,

Try

/Applications/MAMP/Library/bin/mysql -u root

http://my.safaribooksonline.com/9780321606709/app01lev1sec3?portal=oreilly

good luck! Tim

sorry thats

http://www.google.com/url?sa=U&start=6&q=http://my.safaribooksonline.com/9780321606709/app01lev1sec3%3Fportal%3Doreilly&ei=yw5MSbGzHJmWsAOm9PCRDQ&sig2=jV-ITmnlJptkowoubvXwtQ&usg=AFQjCNH315zLo_wW_m0Gs3FGh9fr_sr7Rg

I'd imagine that somewhere under /Applications/MAMP is a directory with a bunch of files with names starting with mysql. Look around, or run this from a prompt:

So I found the folder (who's contents I am going to list in my output in a second) with all the files starting with mysql. It is located here: Applications/MAMP/Library/bin - Here is what an ls of the dir revealed:

bio4054059:bin rmorourk$ ls ab mysql_convert_table_format apachectl mysql_explain_log apr-config mysql_find_rows apu-config mysql_fix_extensions apxs mysql_fix_privilege_tables autopoint mysql_install_db checkgid mysql_secure_installation cjpeg mysql_setpermission comp_err mysql_tableinfo curl mysql_tzinfo_to_sql curl-config mysql_upgrade dbmmanage mysql_upgrade_shell djpeg mysql_waitpid envsubst mysql_zap envvars mysqlaccess envvars-std mysqladmin freetype-config mysqlbinlog gettext mysqlbug gettext.sh mysqlcheck gettextize mysqld_multi htdbm mysqld_safe htdigest mysqldump htpasswd mysqldumpslow httpd mysqlhotcopy httxt2dbm mysqlimport iconv mysqlshow idn mysqltest innochecksum mysqltestmanager jpegtran mysqltestmanager-pwgen libmcrypt-config mysqltestmanagerc libpng-config ngettext libpng12-config perror libtool rdjpgcom libtoolize recode-sr-latin logresolve replace msgattrib resolve_stack_dump msgcat resolveip msgcmp rotatelogs msgcomm sabcmd msgconv sablot-config msgen type1afm msgexec wrjpgcom msgfilter xgettext msgfmt xml2-config msggrep xmlcatalog msginit xmllint msgmerge xslt-config msgunfmt xsltproc msguniq yaz-asncomp msql2mysql yaz-client my_print_defaults yaz-config myisam_ftdump yaz-iconv myisamchk yaz-icu myisamlog yaz-illclient myisampack yaz-marcdump mysql yaz-ztest mysql_client_test zoomsh mysql_config

Assuming this was what I had been searching for, I did this:

bio4054059:bin rmorourk$ echo $PATH /Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/i386/bin:/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/i386/sbin:/Users/rmorourk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin: bio4054059:bin rmorourk$ set PATH=Applications/MAMP/Library/bin:$PATH bio4054059:bin rmorourk$ cd .. .. .. .. .. .. bio4054059:Library rmorourk$ cd .. bio4054059:MAMP rmorourk$ cd .. bio4054059:Applications rmorourk$ cd .. bio4054059:/ rmorourk$ cd Users/rmorourk/Sites/depot/ bio4054059:depot rmorourk$ mysqladmin -u root create depot_devdb -bash: mysqladmin: command not found bio4054059:depot rmorourk$ mysql -U -bash: mysql: command not found bio4054059:depot rmorourk$

As you can see the mysql command still isn't found, any thoughts? I feel like we are getting closer. Thanks for the help thus far!!

I think

set PATH=Applications/MAMP/Library/bin:$PATH

should be

set PATH=/Applications/MAMP/Library/bin:$PATH

looks like it's there and even without setting the path you should be able to do:

/Applications/MAMP/Library/bin/mysql -u root

hope that helps Tim

Ryan Ororie wrote:


So based on this here is what I've done. It seems to be creating the database but then the rake command is saying there is no such database?
bio4054059:depot rmorourk$ /Applications/MAMP/Library/bin/mysql mysqladmin -u root -p root create depot_development
/Applications/MAMP/Library/bin/mysql Ver 14.12 Distrib 5.0.41, for apple-darwin8.11.1 (i686) using EditLine wrapper
Copyright (C) 2002 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Usage: /Applications/MAMP/Library/bin/mysql [OPTIONS] [database]

Whenever you see a message starting “Usage:” it means you did not give the correct options and the program will then go on and tell you what the options really are (in this case in a lot of detail). You in this case entered the wrong command: You apparently entered:

/Applications/MAMP/Library/bin/mysql mysqladmin -u root -p root create depot_development

and correctly got an error message from mysql telling you that the options were all screwed up.

What you really want is:

/Applications/MAMP/Library/bin/mysqladmin -u root -p root create depot_development

This will probably work and give you no output message (most Unix/Linux commands are silent on success). Mysqladmin is a standalone command not a subcommand of mysql. You probably should not have to enter the full pathname but it will work.

Norm

What you really want is: /Applications/MAMP/Library/bin/mysqladmin -u root -p root create depot_development

Interesting, thanks... but now I am getting a problem with the password. Observe:

bio4054059:depot rmorourk$ /Applications/MAMP/Library/bin/mysqladmin -u root -p root create depot_development Enter password: /Applications/MAMP/Library/bin/mysqladmin: Unknown command: 'root' bio4054059:depot rmorourk$

When prompted for the password I typed root - which is what the password is (at least in the database.yml file) but it gives me an unknown command output?

Ryan Ororie wrote:

What you really want is:
/Applications/MAMP/Library/bin/mysqladmin -u root -p root create
depot_development

Interesting, thanks... but now I am getting a problem with the password. Observe:
bio4054059:depot rmorourk$ /Applications/MAMP/Library/bin/mysqladmin -u root -p root create depot_development
Enter password:
/Applications/MAMP/Library/bin/mysqladmin: Unknown command: 'root'
bio4054059:depot rmorourk$
When prompted for the password I typed root - which is what the password is (at least in the database.yml file) but it gives me an unknown command output?

Rather inconsistently there should be a space between the -u and the username but there must not be a space between the -p and the password.

an alternative is to use:

mysqladmin --user=root --password=root create depot_development

notice the double minus on the options in this form. man mysqladmin will give you information on the options and usage of the command.

Norm

OK so now we know you're using bash, substitute "echo" for "print" in my previous mail. Rick