Unable to connect to MySQL.
Moderator: General Moderators
-
homebrewpc
- Forum Newbie
- Posts: 7
- Joined: Mon Apr 03, 2006 9:18 am
Unable to connect to MySQL.
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.
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.
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.
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.
-
homebrewpc
- Forum Newbie
- Posts: 7
- Joined: Mon Apr 03, 2006 9:18 am
Hello,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.
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.
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
check to be done
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 :
And save the file and try browsing the phpmyadmin again.
Hope this might help you.
Cheers,
Dibyendra
Code: Select all
C:> mysql -h localhost -u root -pIf 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]Hope this might help you.
Cheers,
Dibyendra
Last edited by dibyendrah on Wed Apr 12, 2006 6:37 am, edited 1 time in total.
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
checks to be done 2
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
Cheers,
Dibyendra
-
homebrewpc
- Forum Newbie
- Posts: 7
- Joined: Mon Apr 03, 2006 9:18 am
Re: check to be done
Hi dibyendrah,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.Code: Select all
C:> mysql -h localhost -u root -p
If it's ok, then go to the phpmyadmin folder and open the config.inc.php and edit the following line in the file :
And save the file and try browsing the phpmyadmin again.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]
Hope this might help you.
Cheers,
Dibyendra
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.
Last edited by homebrewpc on Wed Apr 12, 2006 11:21 am, edited 1 time in total.
-
homebrewpc
- Forum Newbie
- Posts: 7
- Joined: Mon Apr 03, 2006 9:18 am
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)).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.
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
-
homebrewpc
- Forum Newbie
- Posts: 7
- Joined: Mon Apr 03, 2006 9:18 am
Hi Everah,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.
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
homebrewpc wrote:Managed to get mysqltest.php to work after creating a MySQL password however was unable to log onto phpMyAdmin afterwards.
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.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
Also, have you looked into your my.cnf to make sure that there is NO mention of old_passwords in your [mysqld] section?
-
homebrewpc
- Forum Newbie
- Posts: 7
- Joined: Mon Apr 03, 2006 9:18 am
Hi Everah,Everah wrote:homebrewpc wrote:Managed to get mysqltest.php to work after creating a MySQL password however was unable to log onto phpMyAdmin afterwards.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.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
Also, have you looked into your my.cnf to make sure that there is NO mention of old_passwords in your [mysqld] section?
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Get to the mysql command prompt. When you are there follow these steps:homebrewpc wrote:... can you please explain how to go about running a query that shows all rows of the mysql.user table.
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.
The mysql configuration file is usually located in /etc/. Look in the section under [mysqld] for old_password or old_passwords = 1.homebrewpc wrote:Shall check the my.cnf (providing that I can find where this file is)...
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: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)?:-
Are these your current users?homebrewpc wrote: User Host Password Global privileges Grant
pma localhost No USAGE No
root localhost Yes ALL PRIVILEGES Yes
-
homebrewpc
- Forum Newbie
- Posts: 7
- Joined: Mon Apr 03, 2006 9:18 am
Hi Everah,
Thank you.
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?.
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.
Thank you.
This has resulted in the following error message:-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.
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?.
Thank you. Shall check this.The mysql configuration file is usually located in /etc/. Look in the section under [mysqld] for old_password or old_passwords = 1.
Thank you. Makes a little more sense now.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.
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
Your help in getting this up and running is appreciated.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA