# mySQL setup - I'm losing it here.

**URL:** <https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543>\
**Category:** rubyonrails-talk\
**Created:** [December 19, 2008, 7:19pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543 "2008-12-19T19:19:24Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [December 19, 2008, 7:19pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/1 "2008-12-19T19:19:24Z")

</div>

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:

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

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

&nbsp;&nbsp;&nbsp;&nbsp;bio4054059:depot rmorourk$ rake db:migrate &nbsp;&nbsp;&nbsp;&nbsp;(in /Users/rmorourk/Sites/depot) &nbsp;&nbsp;&nbsp;&nbsp;rake aborted! &nbsp;&nbsp;&nbsp;&nbsp;Unknown database 'depot\_development'

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

&nbsp;&nbsp;&nbsp;&nbsp;development: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adapter: mysql &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;database: depot\_development &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username: root &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password: root &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;host: localhost &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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;

&nbsp;&nbsp;&nbsp;&nbsp;bio4054059:depot rmorourk$ mysql -uroot depot\_development &nbsp;&nbsp;&nbsp;&nbsp;-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!!

---

<div class="post-metadata">

**Author:** ![sadathiru](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@sadathiru](https://discuss.rubyonrails.org/u/sadathiru)\
**Post date:** [December 19, 2008, 7:32pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/2 "2008-12-19T19:32:13Z")

</div>

Hello Ryan,

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Make sure you have only one mysql in ur machine and there is database with name 'depot\_development' and try again.

Thanks, Sadeesh.

---

<div class="post-metadata">

**Author:** ![Rick3](https://avatars.discourse-cdn.com/v4/letter/r/ecb155/32.png) [@Rick3](https://discuss.rubyonrails.org/u/Rick3)\
**Post date:** [December 19, 2008, 7:46pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/3 "2008-12-19T19:46:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hassan](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/hassan/32/714_2.png) [@hassan](https://discuss.rubyonrails.org/u/hassan)\
**Post date:** [December 19, 2008, 7:48pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/4 "2008-12-19T19:48:39Z")

</div>

> 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.
> 
> &nbsp;&nbsp;&nbsp;bio4054059:depot rmorourk$ rake db:migrate &nbsp;&nbsp;&nbsp;(in /Users/rmorourk/Sites/depot) &nbsp;&nbsp;&nbsp;rake aborted! &nbsp;&nbsp;&nbsp;Unknown database 'depot\_development'

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

> when I am in the terminal and I want to do something with the database, like;
> 
> &nbsp;&nbsp;&nbsp;bio4054059:depot rmorourk$ mysql -uroot depot\_development &nbsp;&nbsp;&nbsp;-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,

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [December 19, 2008, 7:52pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/5 "2008-12-19T19:52:32Z")

</div>

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..

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [December 19, 2008, 8:02pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/6 "2008-12-19T20:02:19Z")

</div>

> 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](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!

---

<div class="post-metadata">

**Author:** ![Freddy\_Andersen](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@Freddy\_Andersen](https://discuss.rubyonrails.org/u/Freddy_Andersen)\
**Post date:** [December 19, 2008, 8:03pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/7 "2008-12-19T20:03:10Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![hassan](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/hassan/32/714_2.png) [@hassan](https://discuss.rubyonrails.org/u/hassan)\
**Post date:** [December 19, 2008, 8:31pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/8 "2008-12-19T20:31:24Z")

</div>

> First, how do I add it to my PATH? Second, I used this to install mySQL: [http://www.mamp.info/en/index.php](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 🙂

> 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,

---

<div class="post-metadata">

**Author:** ![Tim3](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tim3](https://discuss.rubyonrails.org/u/Tim3)\
**Post date:** [December 19, 2008, 9:19pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/9 "2008-12-19T21:19:58Z")

</div>

Try

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

[http://my.safaribooksonline.com/9780321606709/app01lev1sec3?portal=oreilly](http://my.safaribooksonline.com/9780321606709/app01lev1sec3?portal=oreilly)

good luck! Tim

---

<div class="post-metadata">

**Author:** ![Tim3](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tim3](https://discuss.rubyonrails.org/u/Tim3)\
**Post date:** [December 19, 2008, 9:24pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/10 "2008-12-19T21:24:47Z")

</div>

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](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)

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [December 19, 2008, 11:46pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/11 "2008-12-19T23:46:21Z")

</div>

> 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!!

---

<div class="post-metadata">

**Author:** ![Tim3](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tim3](https://discuss.rubyonrails.org/u/Tim3)\
**Post date:** [December 19, 2008, 11:54pm UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/12 "2008-12-19T23:54:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Norm2](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@Norm2](https://discuss.rubyonrails.org/u/Norm2)\
**Post date:** [December 20, 2008, 3:03am UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/13 "2008-12-20T03:03:20Z")

</div>

Ryan Ororie wrote:

> > ```ruby
> > 
> > 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

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [December 20, 2008, 3:12am UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/14 "2008-12-20T03:12:30Z")

</div>

> 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?

---

<div class="post-metadata">

**Author:** ![Norm2](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@Norm2](https://discuss.rubyonrails.org/u/Norm2)\
**Post date:** [December 20, 2008, 3:23am UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/15 "2008-12-20T03:23:04Z")

</div>

Ryan Ororie wrote:

> > ```ruby
> > What you really want is:
> > /Applications/MAMP/Library/bin/mysqladmin -u root -p root create
> > depot_development
> > 
> > ```
> 
> ```ruby
> 
> 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

---

<div class="post-metadata">

**Author:** ![Rick3](https://avatars.discourse-cdn.com/v4/letter/r/ecb155/32.png) [@Rick3](https://discuss.rubyonrails.org/u/Rick3)\
**Post date:** [December 20, 2008, 6:25am UTC](https://discuss.rubyonrails.org/t/mysql-setup-im-losing-it-here/37543/16 "2008-12-20T06:25:23Z")

</div>

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