You are not logged in.

#1 2005-02-13 20:13:28

Virtual DarKness
Member
From: Italy
Registered: 2004-04-02
Posts: 32
Website

use php mysql extension with mysql 4.1

I have installed (using pacman)

- apache 2.0.53
- php 5.0.3
- mysql 4.1.9
- phpmyadmin 2.6.1

now.. phpmyadmin works fine with http auth method if I try to login as root without a password.. then if I change the mysql password with

/usr/bin/mysqladmin -u root -p password 'newpass'

i'm no longer able to loing both using "newpass" or using an empty pass..

this is the error I get from phpmyadmin:

Welcome to phpMyAdmin 2.6.1

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in config.inc.php and make sure that they correspond to the information given by the administrator of the MySQL server.
Error

MySQL said:
#1045 - Access denied for user 'root'@'localhost' (using password: NO)

any idea? thanks.

bye,
Giovanni.


Linux registered user #72162

Offline

#2 2005-02-13 22:28:10

Virtual DarKness
Member
From: Italy
Registered: 2004-04-02
Posts: 32
Website

Re: use php mysql extension with mysql 4.1

update: this is not a problem related only to phpmyadmin..

I've tried with this simple php code:

<?php

$link = mysql_connect('127.0.0.1', 'root', 'mypass');
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);


?>

and this was the output:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in /home/httpd/html/index.php on line 3
Could not connect: Access denied for user 'root'@'localhost' (using password: NO)

once again if I set the password to null with

mysqladmin -u root -h localhost password -p ''

and I try to reload the page I get this:

Connected successfully

also mysql works from console both with/without a password. so I think is a problem related to apache/php, not to mysql..

thanks in advice for your help.

bye,
Giovanni.

p.s.
this is the mysql section of phpinfo:

mysql
MySQL Support    enabled
Active Persistent Links     0
Active Links     0
Client API version     4.1.9
MYSQL_MODULE_TYPE     external
MYSQL_SOCKET     /tmp/mysql.sock
MYSQL_INCLUDE     -I/usr/include/mysql
MYSQL_LIBS     -L/usr/lib -lmysqlclient

Directive    Local Value    Master Value
mysql.allow_persistent    On    On
mysql.connect_timeout    60    60
mysql.default_host    no value    no value
mysql.default_password    no value    no value
mysql.default_port    no value    no value
mysql.default_socket    no value    no value
mysql.default_user    no value    no value
mysql.max_links    Unlimited    Unlimited
mysql.max_persistent    Unlimited    Unlimited
mysql.trace_mode    Off    Off

Linux registered user #72162

Offline

#3 2005-02-13 23:40:15

Virtual DarKness
Member
From: Italy
Registered: 2004-04-02
Posts: 32
Website

Re: use php mysql extension with mysql 4.1

ok found the problem: i've to connect to mysql using mysqli :!:  :!:

someone should add it (commented) to the default php.it after the mysql.so extension wink

bye,
Giovanni.


Linux registered user #72162

Offline

#4 2005-02-14 12:34:29

Virtual DarKness
Member
From: Italy
Registered: 2004-04-02
Posts: 32
Website

Re: use php mysql extension with mysql 4.1

mysqli worked with phpmyadmin but doesn't works with my scripts and right now I don't have the time to rewrite them wink

Is it possible to continue use php5+mysql4.1 without mysqli (just with the old mysql) extension?

Or will I have to downgrade to an older version of php/mysql? and in this case: where do I find them (tried to search on the forum and ftp mirrors but nothing..).

please let me know, thanks.

bye,
Giovanni.


Linux registered user #72162

Offline

#5 2005-02-14 15:17:44

freakyc
Member
Registered: 2004-03-28
Posts: 89

Re: use php mysql extension with mysql 4.1

I don't think you should need to use mysqli.  Your test code works fine here, even after changing my password back and forth, making sure your mysqladmin syntax would work fine.

There is an option, old-password, that can be used in place of, password, which I was going to suggest trying as mysqli is supposed to enable some added features of mysql 4.1, and the help for mysqladmin says that 'password' uses 4.1 hashing.  But I don't seem to need it here, so I'm not sure.

Also, why is your test script reporting back that you're not using a password?  And is it normal for it to resolve 127.0.0.1 to localhost, which is also in your output.  Actually, I couldn't even get the script to connect properly (different error), until I changed 127.0.0.1 to localhost.

I don't know, something strange going on there.  Possibly something to do with different locale settings?

Offline

#6 2005-02-14 17:54:06

Virtual DarKness
Member
From: Italy
Registered: 2004-04-02
Posts: 32
Website

Re: use php mysql extension with mysql 4.1

hi freakyc,
thanks for your reply.

i've tried the code both with 127.0.01 and localhost but it doesn't work.
you have the same version of mysql/php that I have, right?

This is what I found on php.net:

In MySQL4.1 and later, the default password hashing format has changed making it incompatible with 3.x clients.
I found out mysql_connect() works on server versions >= 4.1 when your MySQL user password is blank because password authentication isn't done in that case, otherwise you need to use another connection method (e.g. mysqli).
Also if you are using old MySQL tables on a new server (i.e. the passwords are stored in the old format), then the server will use the old auth method automatically and this function should work in all cases.
Hopefully this will help someone, it had me confused for a while because some of the users on my 4.1 server could connect and some couldn't.

and about the old_password thing:

mysql -u root-p

SET PASSWORD FOR user@localhost = OLD_PASSWORD('password');

and then another user who wrote:

PHP5.0.3 works perfectly using mysql extension with MySQL4.1, all that has been fixed.

but this is not true for me.. and my situation is exactly the one described in the first block of quoted text that I wrote on this post.. ("works on server versions >= 4.1 when your MySQL user password is blank [...] otherwise you need to use another connection method").

Also, why is your test script reporting back that you're not using a password?

good question.. I don't know.. also because from console I need to specify a password to launch mysql.

Possibly something to do with different locale settings?

once again, I don't know  roll ..any idea of what I could do to test it?

thanks.

bye,
Giovanni.


Linux registered user #72162

Offline

#7 2005-02-14 19:35:07

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,615
Website

Re: use php mysql extension with mysql 4.1

odd. I have no problem using php5 and regular mysql connections.


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#8 2005-02-14 21:23:54

Virtual DarKness
Member
From: Italy
Registered: 2004-04-02
Posts: 32
Website

Re: use php mysql extension with mysql 4.1

cactus wrote:

odd. I have no problem using php5 and regular mysql connections.

sad

what should I do in order to try with a blank configuration? I mean do it again as if it was a fresh install.. just pacman -R (of apache, php, mysql) ? and then clean the /var/lib/mysql folder ?

..mh I've also installed mythtv and launched the database install script but then removed it, could it be the cause (don't think but don't know what to think wink)

can anyone try it from a new install? I've installed arch with the 0.7base beta cd and then installed php and mysql just a few days ago..

thanks.

bye,
Giovanni.


Linux registered user #72162

Offline

#9 2005-02-14 22:06:50

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,615
Website

Re: use php mysql extension with mysql 4.1

http://dev.mysql.com/doc/mysql/en/defau … leges.html

On Unix, both root accounts are for connections from the local host. Connections must be made from the local host by specifying a hostname of localhost for one account, or the actual hostname or IP number for the other....

on Unix, do this:
shell> mysqladmin -u root password "newpwd"
shell> mysqladmin -u root -h host_name password "newpwd"

if you forgot your root password, or made a typo..
http://dev.mysql.com/doc/mysql/en/reset … sions.html

I installed from a .7 cd quite recently (last week? maybe two weeks ago?) for a test machine to do local dev on (in a vmware instance). Everything works fine on it. php5, mysql, etc.
The error you are getting, about not using password, seems to pop out when the improper password is being used. php5 seems to try using no password, if the password provided does not work. ie. it uses some type of "fall back". Dunno specifics though.

In all likelihood it boils down to you not having set BOTH root account passwords.
That is why it appears to be working for one, and not the other. In fact, there are two accounts. One with hostname, one without.

ps. I usually just install phpmyadmin and use that to set passwords and check permissions. But, I am lazy by nature.  wink


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#10 2005-02-14 22:23:13

Virtual DarKness
Member
From: Italy
Registered: 2004-04-02
Posts: 32
Website

Re: use php mysql extension with mysql 4.1

:? I've already tried with it but doesn't work.. I think that the password is ok cause using mysqli it works...

:?:  :?:

bye,
Giovanni.


Linux registered user #72162

Offline

#11 2005-02-16 14:49:01

Virtual DarKness
Member
From: Italy
Registered: 2004-04-02
Posts: 32
Website

Re: use php mysql extension with mysql 4.1

I've tried removing mysql and /var/lib/mysql and then whith a fresh install i noticed, launching mysql_install_db before /etc/rc.d/mysqld start, this error message:

ERROR: 1062  Duplicate entry 'localhost-root' for key 1
ERROR: 1062  Duplicate entry 'localhost-' for key 1
Fill help tables

followed by the normal output:

To start mysqld at boot time you have to copy support-files/mysql.server
to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost password 'new-password'
See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com

can that error be the cause of my problem?

@cactus: does it works for you if you try to do this?:
- backup your /var/lib/mysql folder
- stop the mysql daemon
- remove mysql
- delete the mysql user and the mysql group
- rename/delete the /var/lib/mysql folder
- install mysql with pacman -Sy mysql
- start the mysql daemon (it should install the db and create user/group)
- set a password with:
/usr/bin/mysqladmin -u root password 'mypass'
/usr/bin/mysqladmin -u root -p -h localhost password 'mypass'

then try to run the php code I wrote on my second post in this thread..
..you should get the same error I've reported on my post under the php code..

let me know if you can try it.. thanks.
btw what do you mean with "improper password" ?

bye,
Giovanni.


Linux registered user #72162

Offline

Board footer

Powered by FluxBB