Page 1 of 2
Unable to connect to MySQL.
Posted: Mon Apr 03, 2006 9:20 am
by homebrewpc
Hi,
I'm a complete newbie to php and MySQL and would really like to learn php and have made a start on reading through PHP 5 in Easy Steps and, unfortunately have come across a stumbling block already Sad.
I've installed Apache, php and MySQL via an XAMPP download as opposed to downloading the individual components seperately (not sure if this is good or bad).
phpinfo.php works alright however mysqltest.php does not and produces the following error message:-
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in C:\Program Files\xampp\htdocs\xampp\in_easy_steps\mysqltest.php on line 7
sorry unable to connect to MySQL
As i'd installed XAMPP several months ago and forgotten the MySQL password that was set-up i've tried to reset the password however without avail.
http://dev.mysql.com/doc/refman/5.0/en/ ... sions.html
Any suggestions on how to get MySQL up and running again would be appreciated.
Thank you.
Kind Regards.
Posted: Mon Apr 03, 2006 9:57 am
by neophyte
Check to see if mysql is running in your task manager.
Check your xampp control panel is it running?
Open a terminal and cd inot the xampp - mysql -bin diretory see if you can connect that way.
If you installed a stand alone mysql xampp may be competeing for ports.
Go to services and check to see what is running.
Hope those suggestions help.
Posted: Tue Apr 11, 2006 7:20 pm
by homebrewpc
neophyte wrote:Check to see if mysql is running in your task manager.
Check your xampp control panel is it running?
Open a terminal and cd inot the xampp - mysql -bin diretory see if you can connect that way.
If you installed a stand alone mysql xampp may be competeing for ports.
Go to services and check to see what is running.
Hope those suggestions help.
Hello,
Thank you. Am a little confused. Managed to get mysqltest.php to work after creating a MySQL password however was unable to log onto phpMyAdmin afterwards . Deleted XAMPP installation as wanted to run Apache, MySQL and php on a USB Stick. Am now running Uniserver on a USB Stick however am up against the same stumbling block. phpinfo suggests that php is working correctly however the mysqltest.php page results in the error message mentioned initially. Are there any important checks that need to be done or accounts/privileges set up in phpMyAdmin prior to mysqltest.php being able to work?.
Thank you.
check to be done
Posted: Wed Apr 12, 2006 6:32 am
by dibyendrah
Please check from the console (command mode) like below :
Provide the password and if it connects as usual, then you have mysql running or else see the mysqld.exe in the process list.
If it's ok, then go to the phpmyadmin folder and open the config.inc.php and edit the following line in the file :
Code: Select all
/* Server Dibyendra (config:root) [1] */
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
[b]$cfg['Servers'][$i]['password'] = 'password'; <- change to be made[/b]
And save the file and try browsing the phpmyadmin again.
Hope this might help you.
Cheers,
Dibyendra
checks to be done 2
Posted: Wed Apr 12, 2006 6:33 am
by dibyendrah
if error occurs in console that couldn't connect then mysql server is not running. if access denied to root@localhost appears then password is wrong.
Cheers,
Dibyendra
Re: check to be done
Posted: Wed Apr 12, 2006 11:05 am
by homebrewpc
dibyendrah wrote:Please check from the console (command mode) like below :
Provide the password and if it connects as usual, then you have mysql running or else see the mysqld.exe in the process list.
If it's ok, then go to the phpmyadmin folder and open the config.inc.php and edit the following line in the file :
Code: Select all
/* Server Dibyendra (config:root) [1] */
$i++;
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
[b]$cfg['Servers'][$i]['password'] = 'password'; <- change to be made[/b]
And save the file and try browsing the phpmyadmin again.
Hope this might help you.
Cheers,
Dibyendra
Hi dibyendrah,
Thank you for your replies. Much appreciated. Please excuse my sheer ignorance but i'm lost as to what you've asked that I check. Please bear with me and i'll explain what's been done so far.
Basically i'm running Uniserver from a USB Stick rather than from hard disk and phpinfo has confirmed that the php engine itself is working (not sure if that's the correct terminology) and phpMyAdmin is working (re-installed, no databases have been created nor passwords).
I double click on Disk Start.vbs in order for Apache, php and MySQL to start. A pop up message confirms that the Server Drive is allocated drive letter W: which from what I understand is a virtual drive whilst Uniserver is running. Immediately after this is confirmed another pop up message asks whether or not to Start the MySQL Database Server (the yes button is clicked).
All php work that i'm putting together as I learn is saved into the W: drive (into a WWW directory or folder).
Like I say phpinfo.php saved into the WWW directory confirms that the php engine is working however the mysqltest.php that's saved into the WWW directory produces the following error message:-
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in W:\www\mysqltest.php on line 7
sorry - unable to connect to MySQL
If you could advise in newbie terms what exactly needs to be done in order to fix this problem i'd be grateful.
Am running Uniserver from the Desktop at the moment. The path that Mysql is in is as follows:-
C:\Documents and Settings\Administrator\Desktop\Uniform Server\diskw\usr\local\mysql\bin
Do I need to go to that folder via command prompt and type in "mysql -h localhost -u root -p"?
Edit:-
At the command prompt i've typed in "mysql -h localhost -u root -p" at the path mentioned above,
entered in a password that's been created and the following message appears:-
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.17
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Guess that MySQL is running however the same error message appears upon entering
http://localhost/mysqltest.php into a browser window

.
Your comments would be appreciated

.
Thank you.
Kind Regards.
Posted: Wed Apr 12, 2006 11:18 am
by Weirdan
press Win+R, type 'cmd', press enter. Win is a 'Windows key', usually it's located between Alt and Ctrl. Command prompt window (black, DOS-like) will appear. Type there the command dibyendrah was suggesting.
Posted: Wed Apr 12, 2006 11:34 am
by homebrewpc
Weirdan wrote:press Win+R, type 'cmd', press enter. Win is a 'Windows key', usually it's located between Alt and Ctrl. Command prompt window (black, DOS-like) will appear. Type there the command dibyendrah was suggesting.
Hi, Thank you for your reply. Typed what dibyendrah suggested but the mysqltest.php still doesn't connect to MySQL (even though MySQL has been confirmed as running (to the best of my knowledge)).
Is there anything in phpMyAdmin that needs to be configured accordingly prior to the mysqltest.php working?.
Upon clicking on privelages the following details are shown:-
User Host Password Global privileges Grant
pma localhost No USAGE No
root localhost Yes ALL PRIVILEGES Yes
Note: MySQL privilege names are expressed in English
Not sure why "(Using Password:NO)" is illustrated in the error message that's shown in a browser window (via
http://localhost/mysqltest.php) as i've phpMyAdmin says Password-Yes.
Really confused

.
Your comments would be appreciated.
Thank you.
Kind Regards.
Posted: Wed Apr 12, 2006 11:59 am
by RobertGonzalez
homebrewpc,
In your PHP info page, look at the MySQL portion and reply back with the version number for Client API version. If it is anything 3.28.X or less, then your problem my be in the version of MySQL you are using. MySQL 4.1+ does not work with the password algorithm used by MySQL API 3.28.
Posted: Wed Apr 12, 2006 4:31 pm
by homebrewpc
Everah wrote:homebrewpc,
In your PHP info page, look at the MySQL portion and reply back with the version number for Client API version. If it is anything 3.28.X or less, then your problem my be in the version of MySQL you are using. MySQL 4.1+ does not work with the password algorithm used by MySQL API 3.28.
Hi Everah,
Thank you for your reply. I've cheched the MySQL Client API version and it's 4.1.7. If you can offer any further suggestions and a possible fix to the problem with being unable to connect to MySQL database i'd be grateful.
Kind Regards.
Posted: Wed Apr 12, 2006 4:54 pm
by RobertGonzalez
homebrewpc wrote:Managed to get mysqltest.php to work after creating a MySQL password however was unable to log onto phpMyAdmin afterwards.
homebrewpc wrote:At the command prompt i've typed in "mysql -h localhost -u root -p" at the path mentioned above,
entered in a password that's been created and the following message appears:-
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.17
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Guess that MySQL is running however the same error message appears upon entering
http://localhost/mysqltest.php into a browser window
This means that mysql is running and that you can connect to it. There is something going on between your test page and your scripts that is preventing mysql from authenticating the user. Try loggin in to mysql using the prompt and run a query that shows all rows of the mysql.user table. See if there are any other user accounts that you can use to log in. If the scripts still crap out on your then it has to have something to do with passwords.
Also, have you looked into your my.cnf to make sure that there is
NO mention of old_passwords in your [
mysqld] section?
Posted: Wed Apr 12, 2006 6:18 pm
by homebrewpc
Everah wrote:homebrewpc wrote:Managed to get mysqltest.php to work after creating a MySQL password however was unable to log onto phpMyAdmin afterwards.
homebrewpc wrote:At the command prompt i've typed in "mysql -h localhost -u root -p" at the path mentioned above,
entered in a password that's been created and the following message appears:-
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.17
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Guess that MySQL is running however the same error message appears upon entering
http://localhost/mysqltest.php into a browser window
This means that mysql is running and that you can connect to it. There is something going on between your test page and your scripts that is preventing mysql from authenticating the user. Try loggin in to mysql using the prompt and run a query that shows all rows of the mysql.user table. See if there are any other user accounts that you can use to log in. If the scripts still crap out on your then it has to have something to do with passwords.
Also, have you looked into your my.cnf to make sure that there is
NO mention of old_passwords in your [
mysqld] section?
Hi Everah,
Thank you for your reply. Regarding logging in to mysql using the prompt i'm o.k. with that but can you please explain how to go about running a query that shows all rows of the mysql.user table.
Shall check the my.cnf (providing that I can find where this file is) and make sure there's no mention of old_passwords in the mysqld section. I've deleted the uniserver folder and its contents on several occasions now though and literally unzipped uniserver so that it's a clean install (on both the Desktop and on USB Stick).
Out of interest what is the difference between these two accounts and are they installed by default (cannot remember whether the root account was created manually or was there automatically)?:-
User Host Password Global privileges Grant
pma localhost No USAGE No
root localhost Yes ALL PRIVILEGES Yes
Thank you.
Kind Regards.
Posted: Wed Apr 12, 2006 6:28 pm
by RobertGonzalez
homebrewpc wrote:... can you please explain how to go about running a query that shows all rows of the mysql.user table.
Get to the mysql command prompt. When you are there follow these steps:
mysql> use mysql;
mysql> show tables; <- This command will list all the tables in mysql database. Make sure user is in here
mysql> select * from user; <- This lists all the users, their hashed passwords and their privileges.
homebrewpc wrote:Shall check the my.cnf (providing that I can find where this file is)...
The mysql configuration file is usually located in /etc/. Look in the section under [
mysqld] for old_password or old_passwords = 1.
homebrewpc wrote:Out of interest what is the difference between these two accounts and are they installed by default (cannot remember whether the root account was created manually or was there automatically)?:-
Not exactly sure what you are asking, but mysql typically installs with one user on two hosts. The user is usually 'root' and the hosts are usually '' and 'localhost'. Root typically has global Grant privileges for all databases.
homebrewpc wrote:
User Host Password Global privileges Grant
pma localhost No USAGE No
root localhost Yes ALL PRIVILEGES Yes
Are these your current users?
Posted: Wed Apr 12, 2006 6:49 pm
by homebrewpc
Hi Everah,
Thank you.
Get to the mysql command prompt. When you are there follow these steps:
mysql> use mysql;
mysql> show tables; <- This command will list all the tables in mysql database. Make sure user is in here
mysql> select * from user; <- This lists all the users, their hashed passwords and their privileges.
This has resulted in the following error message:-
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql' at line 1
This probably isn't helping the problem that's being experienced at a guess. Any ideas how to fix this please?.
The mysql configuration file is usually located in /etc/. Look in the section under [mysqld] for old_password or old_passwords = 1.
Thank you. Shall check this.
Not exactly sure what you are asking, but mysql typically installs with one user on two hosts. The user is usually 'root' and the hosts are usually '' and 'localhost'. Root typically has global Grant privileges for all databases.
Thank you. Makes a little more sense now.
User Host Password Global privileges Grant
pma localhost No USAGE No
root localhost Yes ALL PRIVILEGES Yes
[/quote]
Are these your current users?.
Yes. Am a little confused as to the Password-Yes and the Password-No though (in the error message that's appearing upon entering mysqltest.pho into a browser window.
Sorry for knowing absolutely nothing on this subject. Am keen to learn but nothing ever seems straight forward

. The book that i'm working through doesn't mention anything about problems that readers might come across with using the MySQL test script (just my luck to be experiencing problems I guess).
Your help in getting this up and running is appreciated.
Posted: Wed Apr 12, 2006 6:58 pm
by RobertGonzalez
Nice. OK, at the very first mysql prompt, enter this:
mysql> show databases;
What does that produce?