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

select database();

and it just gives me a null! I've already created a database (I've been
following Agile Web Development 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 Arbon 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

>select database();

and it just gives me a null! I've already created a database (I've been
following Agile Web Development 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.

Robert Arbon wrote:

Robert Arbon 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

>select database();

and it just gives me a null! I've already created a database (I've been
following Agile Web Development 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.

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

>select database();

and it just gives me a null!

Uh, no surprise -- where did you find that "command"? In any case,

SHOW DATABASES;

  ...list of databases will be displayed...

USE foo_development;
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 Schroeder wrote:

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

>select database();

and it just gives me a null!

Uh, no surprise -- where did you find that "command"? In any case,

> SHOW DATABASES;
  ...list of databases will be displayed...
> USE foo_development;
> 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 Schroeder ------------------------ hassan.schroeder@gmail.com

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:

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:

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

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

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