Because a default install of MySQL includes an anonymous user, one with no username or password. There is also a root user with no password. Read the MySQL manual on Installation and the GRANT command on how to fix this.
---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ > -----Original Message----- > From: Anthony Ritter [mailto:[EMAIL PROTECTED]] > Sent: Sunday, February 02, 2003 3:16 PM > To: [EMAIL PROTECTED] > Subject: [PHP] php/mysql connection > > Newbie question and OT. Sorry. > > I am able to conncet to a mysql server with the following call to > mysql_connect(). > $connect=@mysql_connect("","",""); > > There are no parameters in the function call. > > Why can I connect if there are no parameters? > > However, if I give mysqladmin the password of: > goodpassword > > and call: > > $connect=@mysql_connect("localhost","root","goodpassword"); > > I connect. > > But if I call: > $connect=@mysql_connect("localhost","root","badpassword"); > > I cannot connect. > > Or from the command line... > > >From the command line: > C:\Windows\cd c:\mysql\bin \\enter > > C:\mysql\bin> mysqld-shareware --standalone \\enter > > C:\mysql\bin> mysql \\enter note: no password have been entered. > > \\ I get the: Welcome to the MySql monitor... > ............................... > Or... > > C:\Windows\cd c:\mysql\bin \\enter > > C:\mysql\bin> mysqld-shareware --standalone \\enter > > C:\mysql\bin> mysql -u root - p \\ enter > > Enter password goodpassword \\ I get the: Welcome to the MySql monitor... > > > ............................ > C:\Windows\cd c:\mysql\bin \\enter > > C:\mysql\bin> mysqld-shareware --standalone \\enter > > C:\mysql\bin> mysql -u root - p \\ enter > Enter password badpassword \\ I do _not_ get the: Welcome to the MySql > monitor... > ........................ > > Why is this when I thought it needs a password to connect to the MySql > monitor? > Thanks, > TR > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php