Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to MySQL with hashed password?

I was wondering (and used Google with no clear result) if there is any way to connect to a MySQL database with PHP using a hashed password. Say I have the following:

Password (plain): 'foobar'
Password (sha1): '8843d7f92416211de9ebb963ff4ce28125932878'

Now I would like to connect to MySQL like this (using the mysql_* function as example, I'm using PDO though):

$db_link = mysql_connect ( 'localhost', 'user', '8843d7f92416211de9ebb963ff4ce28125932878' );

I this possible? Have anyone done this before?

like image 481
Stefan Avatar asked Jul 04 '09 19:07

Stefan


People also ask

Can MySQL hash passwords?

The password hash stored by MySQL Server is generated by hashing the plain-text password twice using SHA1. When the client transmits the password to the server, it uses three pieces of information: The SHA1 hash of the plain text password. The SHA1 hash of the the SHA1 hash of the plain text password.

How do you connect to MySQL as root with some password?

Use the following procedure to set a root password. To change the root password, type the following at the MySQL/MariaDB command prompt: ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyN3wP4ssw0rd'; flush privileges; exit; Store the new password in a secure location.

Does MySQL support hashing?

MySQL uses passwords in two phases of client/server communication: When a client attempts to connect to the server, there is an initial authentication step in which the client must present a password that has a hash value matching the hash value stored in the user table for the account the client wants to use.

How encrypt password MySQL query?

MySQL server uses the PASSWORD function to encrypt MySQL passwords for storage in the Password column of the user grant table. The value returned by the PASSWORD function is a hashed string, or NULL if the argument was NULL. The PASSWORD function accepts one parameter which is the string to be encrypted.


1 Answers

Then the "hash" would be the password. What would be the benefit?

like image 199
VolkerK Avatar answered Oct 18 '22 04:10

VolkerK