Instant Rails and MySQL

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…

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.

2008/1/8 Robert A. [email protected]:

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 :slight_smile:

HTH,

Hassan S. ------------------------ [email protected]

Hassan S. wrote:

2008/1/8 Robert A. [email protected]:

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 :slight_smile:

HTH,

Hassan S. ------------------------ [email protected]

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.

:slight_smile: 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. [email protected]

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.

Brian H. wrote:

:slight_smile: 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. [email protected]

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