# Instant Rails and MySQL

**URL:** <https://www.ruby-forum.com/t/instant-rails-and-mysql/125423>\
**Category:** Rails\
**Created:** [January 8, 2008, 11:32pm UTC](https://www.ruby-forum.com/t/instant-rails-and-mysql/125423 "2008-01-08T23:32:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [January 8, 2008, 11:32pm UTC](https://www.ruby-forum.com/t/instant-rails-and-mysql/125423/1 "2008-01-08T23:32:02Z")

</div>

Just started using Instant rails 1.7. I want to look at the MySQL  
server and see my database. So I type

‘instantrails folder’\>mysql -u root

mysql\>select database();

and it just gives me a null! I’ve already created a database (I’ve been  
following Agile Web D. with RoR). Don’t know a huge amount  
about how MySQL works but what I’ve read so far doesn’t get me anywhere.

Thanks for your time…

---

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [January 9, 2008, 10:40am UTC](https://www.ruby-forum.com/t/instant-rails-and-mysql/125423/2 "2008-01-09T10:40:08Z")

</div>

Robert A. wrote:

> Just started using Instant rails 1.7. I want to look at the MySQL  
> server and see my database. So I type
> 
> ‘instantrails folder’\>mysql -u root
> 
> mysql\>select database();
> 
> and it just gives me a null! I’ve already created a database (I’ve been  
> following Agile Web D. with RoR). Don’t know a huge amount  
> about how MySQL works but what I’ve read so far doesn’t get me anywhere.
> 
> Thanks for your time…

I also installed the GUI ‘MySQL Admin’ but that doesn’t seem to want to  
connect to ‘local host’. I have it running in a directory outside the  
‘Instant Rails’ directory if that helps.

---

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [January 9, 2008, 4:23pm UTC](https://www.ruby-forum.com/t/instant-rails-and-mysql/125423/3 "2008-01-09T16:23:24Z")

</div>

2008/1/8 Robert A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Just started using Instant rails 1.7. I want to look at the MySQL

> mysql\>select database();
> 
> and it just gives me a null!

Uh, no surprise – where did you find that “command”? In any case,

mysql\> SHOW DATABASES;  
…list of databases will be displayed…  
mysql\> USE foo\_development;  
mysql\> SHOW TABLES;  
…list of tables will be displayed…

Reading a basic SQL book or tutorial plus skimming the MySQL  
documentation would probably be a good idea 🙂

## HTH,

Hassan S. ------------------------ removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [January 9, 2008, 4:40pm UTC](https://www.ruby-forum.com/t/instant-rails-and-mysql/125423/4 "2008-01-09T16:40:29Z")

</div>

Hassan S. wrote:

> 2008/1/8 Robert A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > Just started using Instant rails 1.7. I want to look at the MySQL
> 
> > mysql\>select database();
> > 
> > and it just gives me a null!
> 
> Uh, no surprise – where did you find that “command”? In any case,
> 
> mysql\> SHOW DATABASES;  
> …list of databases will be displayed…  
> mysql\> USE foo\_development;  
> mysql\> SHOW TABLES;  
> …list of tables will be displayed…
> 
> Reading a basic SQL book or tutorial plus skimming the MySQL  
> documentation would probably be a good idea 🙂
> 
> ## HTH,
> 
> Hassan S. ------------------------ removed\_email\_address@domain.invalid

Thanks! I had actually done the MySQL tutorial…and looked there  
before I posted (honest!)

I just realised my confusion…my commands show what databases are  
currently selected…I was reading the wrong section.

HOWEVER…

I thought though that the database I was using with instant rails would  
be ‘connected’ (i.e. I was working on it at the time and had just  
created a new table) so my command:

mysql\>select database();

Should be valid non? I had just read this bit in the docs:

3.4. Getting Information About Databases and Tables

What if you forget the name of a database or table, or what the  
structure of a given table is (for example, what its columns are  
called)? MySQL addresses this problem through several statements that  
provide information about the databases and tables it supports.

You have previously seen SHOW DATABASES, which lists the databases  
managed by the server. To find out which database is currently selected,  
use the DATABASE() function:

mysql\> SELECT DATABASE();  
±-----------+  
| DATABASE() |  
±-----------+  
| menagerie |  
±-----------+

Thanks again.

---

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [January 9, 2008, 7:53pm UTC](https://www.ruby-forum.com/t/instant-rails-and-mysql/125423/5 "2008-01-09T19:53:30Z")

</div>

🙂 You don’t quite get what you’re doing. When you log in as you did,  
there’s no database selected. The Rails application has a connection to  
your  
database, but you don’t, since you logged in again as a new connection.

You want USE, not SELECT DATABASE.

use depot\_production;  
select \* from products;  
describe products;

You should investigate using the Rails Console to look at your data.  
It’s  
often faster, and you’ll learn a little more about Ruby that way too.

On Jan 9, 2008 9:40 AM, Robert A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [January 9, 2008, 3:05pm UTC](https://www.ruby-forum.com/t/instant-rails-and-mysql/125423/6 "2008-01-09T15:05:21Z")

</div>

Robert A. wrote:

> > following Agile Web D. with RoR). Don’t know a huge amount  
> > about how MySQL works but what I’ve read so far doesn’t get me anywhere.
> > 
> > Thanks for your time…
> 
> I also installed the GUI ‘MySQL Admin’ but that doesn’t seem to want to  
> connect to ‘local host’. I have it running in a directory outside the  
> ‘Instant Rails’ directory if that helps.

I’m not sure if it’s a typo, but it should be localhost, no space.

Cheers,  
Mohit.  
1/9/2008 | 10:04 PM.

---

<div class="post-metadata">

**Author:** ![ratkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bcef8e/32.png) [@ratkins](https://www.ruby-forum.com/u/ratkins)\
**Post date:** [January 10, 2008, 12:03am UTC](https://www.ruby-forum.com/t/instant-rails-and-mysql/125423/7 "2008-01-10T00:03:02Z")

</div>

Brian H. wrote:

> 🙂 You don’t quite get what you’re doing. When you log in as you did,  
> there’s no database selected. The Rails application has a connection to  
> your  
> database, but you don’t, since you logged in again as a new connection.
> 
> You want USE, not SELECT DATABASE.
> 
> use depot\_production;  
> select \* from products;  
> describe products;
> 
> You should investigate using the Rails Console to look at your data.  
> It’s  
> often faster, and you’ll learn a little more about Ruby that way too.
> 
> On Jan 9, 2008 9:40 AM, Robert A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

By ‘Rails Console’ you mean the Ruby Console? Cos if so, I was using  
the Rails Console.

Oh well, thanks for the input, I think I need to read more about mySQL.

Thanks again
