By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

Error 1044 Access denied to database

P: n/a
Hello.

I am currently working through a book on Dreamweaver and using PHP. I
am having a little trouble with setting up the database though. I
have php 4.2.3 and MySQL 4.0.20a. I am running locally with Apache
1.3.27 on Windows XP Pro.

I seem to have finally got MySQL running after a lot of difficulty.
In the book it says to type source C:\mysql\newland_tours.sql at the
mysql> prompt, to generate the newland_tours database in my copy of
MySQL.

When I do this however it gives me an error message saying:

Error 1044 Access denied for user: '@localhost' to database
'newland_tours'

and numerous other ones saying:

Error 1046 No Database Selected

If you can help me I'd be very grateful. I think that something must
be wrong or amiss with the settings or the paths to the files in
my.ini file? Or perhaps it is just a bug with php or MySql?

Thanks very much for any help

John
Jul 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
John wrote:
I seem to have finally got MySQL running after a lot of difficulty.
In the book it says to type source C:\mysql\newland_tours.sql at the
mysql> prompt, to generate the newland_tours database in my copy of
MySQL.

When I do this however it gives me an error message saying:

Error 1044 Access denied for user: '@localhost' to database
'newland_tours'


Make sure that the correct user is defined in mysql and supply it, e.g.:

path\to\mysql-installation\bin\mysql -uroot -prootpasswd < newland_tours.sql

For more info on priveleges, see:

http://dev.mysql.com/doc/mysql/en/De...rivileges.html and
http://dev.mysql.com/doc/mysql/en/GRANT.html
JW

Jul 20 '05 #2

P: n/a
On Sat, 05 Jun 2004 20:59:00 GMT, "Janwillem Borleffs"
<jw@jwscripts.com> wrote:
John wrote:
I seem to have finally got MySQL running after a lot of difficulty.
In the book it says to type source C:\mysql\newland_tours.sql at the
mysql> prompt, to generate the newland_tours database in my copy of
MySQL.

When I do this however it gives me an error message saying:

Error 1044 Access denied for user: '@localhost' to database
'newland_tours'

Make sure that the correct user is defined in mysql and supply it, e.g.:

path\to\mysql-installation\bin\mysql -uroot -prootpasswd < newland_tours.sql


How exactly do I define correct user and supply it?

When I go to the mysql> prompt do I type in what you have put?

path\to\mysql-installation\bin\mysql -uroot -prootpasswd <
newland_tours.sql

I understand everything here: path\to\mysql-installation\bin\mysql

but I don't have a clue about this: -uroot -prootpasswd <
For more info on priveleges, see:

http://dev.mysql.com/doc/mysql/en/De...rivileges.html and
http://dev.mysql.com/doc/mysql/en/GRANT.html


I have taken a look at these links and all the different sections and
subsections, but it is far too complex for me. I am just a beginner.
I need it explained simply what to do.

Cheers

John
Jul 20 '05 #3

P: n/a
In article <gb********************************@4ax.com>,
John <ph********@needshelp.com> wrote:
On Sat, 05 Jun 2004 20:59:00 GMT, "Janwillem Borleffs"
<jw@jwscripts.com> wrote:
John wrote:
I seem to have finally got MySQL running after a lot of difficulty.
In the book it says to type source C:\mysql\newland_tours.sql at the
mysql> prompt, to generate the newland_tours database in my copy of
MySQL.

When I do this however it gives me an error message saying:

Error 1044 Access denied for user: '@localhost' to database
'newland_tours'


Make sure that the correct user is defined in mysql and supply it, e.g.:

path\to\mysql-installation\bin\mysql -uroot -prootpasswd < newland_tours.sql


How exactly do I define correct user and supply it?

When I go to the mysql> prompt do I type in what you have put?

path\to\mysql-installation\bin\mysql -uroot -prootpasswd <
newland_tours.sql

I understand everything here: path\to\mysql-installation\bin\mysql

but I don't have a clue about this: -uroot -prootpasswd <
For more info on priveleges, see:

http://dev.mysql.com/doc/mysql/en/De...rivileges.html and
http://dev.mysql.com/doc/mysql/en/GRANT.html


I have taken a look at these links and all the different sections and
subsections, but it is far too complex for me. I am just a beginner.
I need it explained simply what to do.

Cheers

John


Buy a book on MySQL and read it. It's whole other rathole in addition
to php. You'll need to understand what a real DBMS is doing and how it
does it. It's not trivial. Be ready for your brain to turn to tapioca
and leak out your ears.

--
DeeDee, don't press that button! DeeDee! NO! Dee...

Jul 20 '05 #4

P: n/a
On Sat, 05 Jun 2004 22:59:01 -0700, "Michael Vilain
<vi****@spamcop.net>" wrote:
Buy a book on MySQL and read it. It's whole other rathole in addition
to php. You'll need to understand what a real DBMS is doing and how it
does it. It's not trivial. Be ready for your brain to turn to tapioca
and leak out your ears.


I already have two books.

John
Jul 20 '05 #5

P: n/a
John wrote:
If you can help me I'd be very grateful. I think that something must
be wrong or amiss with the settings or the paths to the files in
my.ini file? Or perhaps it is just a bug with php or MySql?


It is not a bug, and it has nothing to do with php, so alt.php,
alt.comp.lang.php and comp.lang.php groups are not concerned about this
problem.

And even if this would be problem for php also, don't post to several
different newsgroups. Pick one group and one group only and post your
question to there. If you fail to get help from there, think again was
the group selection good or bad and did you ask the question properly.
If you think yes, then you can try another group. Why you should do
this? Because many people don't usually even bother to answer people who
post the question into many newsgroups, because it is against the
netiquette. This is only a friendly advice, because you might not know
this "rule". Don't be offended by me reminding it.

Now, to your problem.

When you installed MySQL you had a root account at the very beginning.
You might have changed the password for it, but if you havent, the
password is empty. The root user has privileges to do anything in the
database, while test user (which is the user you seem to have logged in,
has privileges only in the "test" database.) Try to start your mysql
console program like this:

mysql -u root

If you can get in, you don't have a root password, but that doesn't
matter with this problem. When you get in, try to type the command you
tried earlier:

source C:\mysql\newland_tours.sql

It should not give the same error anymore.

Follow-ups set to mailing.database.mysql only
Jul 20 '05 #6

P: n/a
On Sat, 05 Jun 2004 21:20:45 +0100, John <ph********@needshelp.com>
wrote:

I seem to have finally got MySQL running after a lot of difficulty.
In the book it says to type source C:\mysql\newland_tours.sql at the
mysql> prompt, to generate the newland_tours database in my copy of
MySQL.


I remember how confusing rhis can be. Before you start loading
databases, you need to know exactly how to log in at the mysql command
line. It gets confusing right there because you log in a bit
differently depending on whether or not you set up a user & password.

First off, you need to see if you can log in correctly. So, open your
Command Prompt and cd to the mysql/bin directory. On my machine, it's:

C:\> cd c:\mysql\bin

Once you get to the correct directory, try logging in without any
username or password like this:

C:\mysql\bin\> mysql

That will log you in as the root user if you haven't already set up a
password for root. If you have set a password up, then you can log in
with it like this:

C:\mysql\bin> mysql -u root -p

And then mysql will prompt you for the root password. The -u stands
for "user", which in this case is root. To log in as egghead, type:

C:\mysql\bin> mysql -u egghead -p

The -p means: prompt me for a password.

Now you can get your database loaded up. It will be easier for you if
you copy the C:\mysql\newland_tours.sql file to the mysql\bin
directory. Once you've done that, cd to the mysql\bin directory as if
you were going to log in, and do this:

C:\mysql\bin\mysql < newland_tours.sql

Or if you have a password,

C:\mysql\bin\mysql -u root -p < newland_tours.sql

And enter the password when prompted. If all goes well, you'll get
dumped back to the original prompt with no messages.

If you get errors, and you probably will:

Check that the database already exists. If not, then log in and create
it.

If it says "No database selected", open up the newland_tours.sql
file in notepad, and on the top line type:

USE DATABASE newland_tours;

or whatever the database name is. That should do it!

Jul 20 '05 #7

P: n/a
Sounds like theres not telling it what user to use - if you haven't set
on up you should be able to use the root user (root@localhost) - as an
aside why not just use easyPHP to set up mysql/apache - it take five
minutes??)
Jul 20 '05 #8

P: n/a
On Sun, 06 Jun 2004 19:09:22 GMT, bill <wh****@whereami.not> wrote:
On Sat, 05 Jun 2004 21:20:45 +0100, John <ph********@needshelp.com>
wrote:

I seem to have finally got MySQL running after a lot of difficulty.
In the book it says to type source C:\mysql\newland_tours.sql at the
mysql> prompt, to generate the newland_tours database in my copy of
MySQL.

I remember how confusing rhis can be. Before you start loading
databases, you need to know exactly how to log in at the mysql command
line. It gets confusing right there because you log in a bit
differently depending on whether or not you set up a user & password.

First off, you need to see if you can log in correctly. So, open your
Command Prompt and cd to the mysql/bin directory. On my machine, it's:

C:\> cd c:\mysql\bin


No probs so far
Once you get to the correct directory, try logging in without any
username or password like this:

C:\mysql\bin\> mysql
Yes when I type this I get the "welcome to the mysql monitor" message
and leaves me at a mysql> sign.
That will log you in as the root user if you haven't already set up a
password for root. If you have set a password up, then you can log in
with it like this:
This is quite strange because when I click on the traffic lights
signal in my taskbar and click show me to open up the MySqlAdmin
interface, and then click on the myini setup tab in there it says
user=house and it has a password that is familiar to me.
C:\mysql\bin> mysql -u root -p

And then mysql will prompt you for the root password. The -u stands
for "user", which in this case is root. To log in as egghead, type:

C:\mysql\bin> mysql -u egghead -p

The -p means: prompt me for a password.

Now you can get your database loaded up. It will be easier for you if
you copy the C:\mysql\newland_tours.sql file to the mysql\bin
directory.
I have copied to this directory as well.
Once you've done that, cd to the mysql\bin directory as if
you were going to log in, and do this:
If I try to CD to that directory from the mysql> after logging in it
gives me errors saying unknown command '\m' and '\b' To be able to CD
to that directory again I have to exit from the mysql monitor by
typing exit or \q and it returns me to the c:\mysql\bin> prompt.
C:\mysql\bin\mysql < newland_tours.sql
If I type this now from the c:\mysql\bin> prompt, it gives me an error
saying:

Error 1044 at line 1, access denied for user "@localhost" to database
'database'
Or if you have a password,

C:\mysql\bin\mysql -u root -p < newland_tours.sql
If I try this with the username and password that are listen in the
my.ini file I get the following error:

Error 1045: Access denied for user: 'house@localhost" <using password:
yes>
And enter the password when prompted. If all goes well, you'll get
dumped back to the original prompt with no messages.

If you get errors, and you probably will:

Check that the database already exists. If not, then log in and create
it.
Yes it exists in both the mysql and the mysql\bin folders on drive C.
If it says "No database selected", open up the newland_tours.sql
file in notepad, and on the top line type:

USE DATABASE newland_tours;
Even after typing this on the first line of the newland_tours.sql file
I still get the same error messages.
or whatever the database name is. That should do it!

John
Jul 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.