This is a discussion on Error 1044 Access denied to database within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello. I am currently working through a book on Dreamweaver and using PHP. I am having a little trouble with ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
On Sat, 05 Jun 2004 22:59:01 -0700, "Michael Vilain
<vilain@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 |
|
|||
|
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 |
|
|||
|
On Sat, 05 Jun 2004 21:20:45 +0100, John <php.newbie@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! |
|
|||
|
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??) |
![]() |
| Thread Tools | |
| Display Modes | |
|
|