danboy712 Posted February 6, 2009 Share Posted February 6, 2009 Hi there I'm going to give myself away as a begginer str8 off. I've been learning PHP, MYSQL & Apache. Managed ok with learning the basics of all 3 seperately (have experience of VB / ASP.net & Microsoft SQL server so understand the theory ok) I worte a test script in php to try connecting to MYSQL using "mysqli()" : <?php $mysqli = new mysqli("localhost", "ODBC", "millcnc", "grocery_store"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { printf("Host information: %s\n", mysqli_get_host_info($mysqli)); } ?> I'm pretty much confident the script is ok and think the problem is in the parameters I am passing to mysqli() it returns the connect failed line every time. Can anyone advise how i reset the username password host etc or retreive them from the MYSQL SERVER I am running all 3 (PHP, MYSQL APACHE) on windows XP and have the latest version of each. many thanks. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted February 6, 2009 Share Posted February 6, 2009 MySQL by default sets up a user with all privileges. This user is root with no password set. Try connecting to mysql with this user. Quote Link to comment Share on other sites More sharing options...
danboy712 Posted February 6, 2009 Author Share Posted February 6, 2009 No still doesn't work I entered root as the user tried it with and without the password (the command line client requests only a password). Apache server error log returns: [Fri Feb 06 15:51:44 2009] [error] [client 127.0.0.1] PHP Warning: mysqli::mysqli() [<a href='mysqli.mysqli'>mysqli.mysqli</a>]: (28000/1045): Access denied for user 'Root'@'localhost' (using password: NO) in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\mysqlconnect.php on line 2 Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted February 6, 2009 Share Posted February 6, 2009 [Fri Feb 06 15:51:44 2009] [error] [client 127.0.0.1] PHP Warning: mysqli::mysqli() [<a href='mysqli.mysqli'>mysqli.mysqli</a>]: (28000/1045): Access denied for user 'Root'@'localhost' (using password: NO) in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\mysqlconnect.php on line 2 mysql is case-sensitive root is not the same as Root. You can reset the root user password by reading this guide Quote Link to comment Share on other sites More sharing options...
danboy712 Posted February 6, 2009 Author Share Posted February 6, 2009 Thanks for that it now appears to accept the password but says the databases are unknown they are on my system so I'll check the configuration and makle sure the file path etc is correct. [Fri Feb 06 16:32:22 2009] [error] [client 127.0.0.1] PHP Warning: mysqli::mysqli() [<a href='mysqli.mysqli'>mysqli.mysqli</a>]: (42000/1049): Unknown database 'fruit_properties' in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\mysqlconnect.php on line 2 The other possibility is alter permissions for each DBase does "root" have access to every database on the server? Quote Link to comment Share on other sites More sharing options...
danboy712 Posted February 6, 2009 Author Share Posted February 6, 2009 Thanks alot had to go out for a bit but got it working. Silly probs to have but at least you only have them once then you know in future finally got the magic output: Host information: localhost via TCP/IP Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.