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