If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Newb Question-- Connecting to databases

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-07-07, 13:23
aiche_ag aiche_ag is offline
Registered User
 
Join Date: Aug 2007
Posts: 3
Newb Question-- Connecting to databases

I am using PHP 5.2 / Apache 2.4 / MySQL 5.0, and using the book Beginning PHP5, Apache, MySQL Web Development by wrox. I am working on configuring php with mysql but one issue I'm having with MySQL is that many of my commands will return the Error 1046: No database selected.

Here is an example of code

C:\>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor..
..
..
mysql>show tables;
ERROR 1046 (3D000): No database selected
mysql>SELECT user, host FROM user;
ERROR 1046 (3D000): No database selected
mysql>show databases;
*---------*
Database
----------
information_schema
mysql
test
--------
3 rows...



------------

As you can see I've got mysql installed and everything, and PHP works with mysql, but I don't know where this error message is coming from. What can I do to fix this? Keep in mind that I don't have an extensive background with setting up networks. Thanks
Reply With Quote
  #2 (permalink)  
Old 08-07-07, 16:07
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
have a look at the USE <database> statement

an alternative to consider is downloading the MYSQL administrator tools from the MySQL website.. this includes adminstrator, query browser amongst others

if you are no up to speed with the MySQL command line then the adminstrator tool can be very useful
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 08-10-07, 05:46
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 770
Yes, as healdem says...
There was nothing wrong with any of the commands you produced, but unfortunately you failed to tell the MySQL command line which database it was you wanted to perform those queries on.
USE test;
will allow you to use the 'test' database and you can then perform any queries you have against that.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On