Question from a new learner of mysql

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
artfhc
Forum Newbie
Posts: 23
Joined: Sun May 23, 2004 11:38 pm
Contact:

Question from a new learner of mysql

Post by artfhc »

I am learning php and mySQL right now by myself, but the problem is that I cannot access the "mySQL" database when I commend this:

Code: Select all

use mysql;
it shows up something like this:
ERROR 1044: Access denied for user: '@localhost' to database 'mysql'
So I tried to use php to testify the connection between mySQL and the server. And it comes out to be fine.

Code: Select all

<?
	$connection = mysql_connect("localhost", "root", "") or
		die("Sorry - unable to connect to mySQL");
	echo("Congraduations - u connected to mySQL.");
?>
The output is:
Congraduations - u connected to mySQL.
So what should I do?
User avatar
Lord Sauron
Forum Commoner
Posts: 85
Joined: Tue Apr 20, 2004 5:53 am
Location: Tilburg, NL

Start learning php

Post by Lord Sauron »

What you should do?

To be honest. I would start reading a php tutorial instead of directly trying to edit some code. Your code doesn't make any sense at all.

Off course the output is 'congratulations' if you are giving the command "echo("Congraduations - u connected to mySQL.");"

And what are trying to do with "use mysql"? Use is no sql command, and neither is mysql.
artfhc
Forum Newbie
Posts: 23
Joined: Sun May 23, 2004 11:38 pm
Contact:

Post by artfhc »

Maybe I didn't explain it clearly. The code below is what I did in the mySQL window.

Code: Select all

mysql> show databases;
+----------+
| Database |
+----------+
| mysql    |
| test     |
+----------+
2 rows in set (0.03 sec)

mysql> use mysql
ERROR 1044: Access denied for user: '@localhost' to database 'mysql'
Thankyou for ur advice, but I actually looked up the "use" keyword from a tutoral book. Maybe I misunderstand how the code works. Please help me.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

try use test; to see what happens
artfhc
Forum Newbie
Posts: 23
Joined: Sun May 23, 2004 11:38 pm
Contact:

Post by artfhc »

Code: Select all

use test;
works. But I need mysql, because "test" is useless.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Re: Start learning php

Post by d3ad1ysp0rk »

Lord Sauron wrote:What you should do?

To be honest. I would start reading a php tutorial instead of directly trying to edit some code. Your code doesn't make any sense at all.

Off course the output is 'congratulations' if you are giving the command "echo("Congraduations - u connected to mySQL.");"

And what are trying to do with "use mysql"? Use is no sql command, and neither is mysql.
You can type commands into the mysql command prompt interface.. ya..
Post Reply