note 48867 deleted from function.mysql-connect by nlopess

From: Date: Mon, 10 Jan 2005 09:39:19 +0000
Subject: note 48867 deleted from function.mysql-connect by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-83033@lists.php.net to get a copy of this message
Note Submitter: Rizwan Kaif ---- CONNECTING MySQL 4.1.x AND PHP 4.3.x ==================================== MYSQL 4.1.X uses a 45 bit password encryption algorithm (SHA-1). But MySQL used to use MD5. Now the problem is that this new algorithm is not compatible with PHP 4.3.X To over come this problem we can do two things, either we can change the password of existing MySQL user according to old MD5 algorithm or we sac simply create a new user with a MD5 password. I would personally prefer to create a new user in MySQL with MD5 Password. To do this follow these steps: 1. Login to MySQL with the 'root' account 2. Create a new user in MySQL using this command: mysql> GRANT usage on myDatabase.* TO myNewUser@localhost; This will create a new user called 'myNewUser' that can connect to the database called 'myDatabase' from localhost. You can change the username and Database name here. If you want to create another user with Administrator rights then use: mysql> GRANT usage on *.* TO myNewUser@localhost; 3. Now we have to set the access rights for the user which we have just created using this command: mysql> GRANT select, insert on myDatabase.* TO myNewUser@localhost; This will grant the select and insert rights on the myDatabase to the myNewUser. If you want to give Administrator rights to myNewUser then use this command: mysql> GRANT ALL on *.* TO myNewUser@localhost; 4. Now we have to change the password but create a short hash (MD5 algorithm). Use the following command: mysql> SET PASSWORD FOR myNewUser@localhost = OLD_PASSWORD('myNewPassword'); 5. Once this has been done, we can connect to MySQL from PHP using mysql_pconnect() or mysql_connect() function. Hope it helps, Rizwan Kaif

« previous php.notes (#83033) next »