Set a password to a pre-hashed value in mysql
How can I set a mysql user's password using a pre-hashed password?
=====
I've got a mysql database version 5.1.73 .
According to the mysql documentation, in the newer versions of mysql, creating a user using a prehashed password
CREATE USER 'ans'@'localhost'
IDENTIFIED BY PASSWORD 'hash_string'
is deprecated and will be removed in a future MySQL release.
However, I cannot figure out what (if anything) is the new way to accomplish this.
We use cobbler to set up our databases, and I would like to pre-populate my databases with the accounts they will need, along with the passwords they will use, without having the clear-text passwords in my scripts. I would have thought
update mysql.user
set password = '*E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB'
where user = 'ans';
would do the trick, but from my testing, that doesn't actually change the mysql login password.
mysql> create user 'ans'@'localhost' identified by 'foo';
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| ans | localhost | *F3A2A51A9B0F2BE2468926B4132313728C250DBF |
+------+-----------+-------------------------------------------+
mysql> update mysql.user set password = password('bar') where user = 'ans';
Query OK, 1 row affected (0.00 sec)
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| ans | localhost | *E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB |
+------+-----------+-------------------------------------------+
mysql> quit
$ mysql -uans -pbar
ERROR 1045 (28000): Access denied for user 'ans'@'localhost' (using password: YES)
$ mysql -uans -pfoo
Welcome to the MySQL monitor. Commands end with ; or g.
passwords mysql hashing
add a comment |
How can I set a mysql user's password using a pre-hashed password?
=====
I've got a mysql database version 5.1.73 .
According to the mysql documentation, in the newer versions of mysql, creating a user using a prehashed password
CREATE USER 'ans'@'localhost'
IDENTIFIED BY PASSWORD 'hash_string'
is deprecated and will be removed in a future MySQL release.
However, I cannot figure out what (if anything) is the new way to accomplish this.
We use cobbler to set up our databases, and I would like to pre-populate my databases with the accounts they will need, along with the passwords they will use, without having the clear-text passwords in my scripts. I would have thought
update mysql.user
set password = '*E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB'
where user = 'ans';
would do the trick, but from my testing, that doesn't actually change the mysql login password.
mysql> create user 'ans'@'localhost' identified by 'foo';
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| ans | localhost | *F3A2A51A9B0F2BE2468926B4132313728C250DBF |
+------+-----------+-------------------------------------------+
mysql> update mysql.user set password = password('bar') where user = 'ans';
Query OK, 1 row affected (0.00 sec)
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| ans | localhost | *E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB |
+------+-----------+-------------------------------------------+
mysql> quit
$ mysql -uans -pbar
ERROR 1045 (28000): Access denied for user 'ans'@'localhost' (using password: YES)
$ mysql -uans -pfoo
Welcome to the MySQL monitor. Commands end with ; or g.
passwords mysql hashing
add a comment |
How can I set a mysql user's password using a pre-hashed password?
=====
I've got a mysql database version 5.1.73 .
According to the mysql documentation, in the newer versions of mysql, creating a user using a prehashed password
CREATE USER 'ans'@'localhost'
IDENTIFIED BY PASSWORD 'hash_string'
is deprecated and will be removed in a future MySQL release.
However, I cannot figure out what (if anything) is the new way to accomplish this.
We use cobbler to set up our databases, and I would like to pre-populate my databases with the accounts they will need, along with the passwords they will use, without having the clear-text passwords in my scripts. I would have thought
update mysql.user
set password = '*E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB'
where user = 'ans';
would do the trick, but from my testing, that doesn't actually change the mysql login password.
mysql> create user 'ans'@'localhost' identified by 'foo';
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| ans | localhost | *F3A2A51A9B0F2BE2468926B4132313728C250DBF |
+------+-----------+-------------------------------------------+
mysql> update mysql.user set password = password('bar') where user = 'ans';
Query OK, 1 row affected (0.00 sec)
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| ans | localhost | *E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB |
+------+-----------+-------------------------------------------+
mysql> quit
$ mysql -uans -pbar
ERROR 1045 (28000): Access denied for user 'ans'@'localhost' (using password: YES)
$ mysql -uans -pfoo
Welcome to the MySQL monitor. Commands end with ; or g.
passwords mysql hashing
How can I set a mysql user's password using a pre-hashed password?
=====
I've got a mysql database version 5.1.73 .
According to the mysql documentation, in the newer versions of mysql, creating a user using a prehashed password
CREATE USER 'ans'@'localhost'
IDENTIFIED BY PASSWORD 'hash_string'
is deprecated and will be removed in a future MySQL release.
However, I cannot figure out what (if anything) is the new way to accomplish this.
We use cobbler to set up our databases, and I would like to pre-populate my databases with the accounts they will need, along with the passwords they will use, without having the clear-text passwords in my scripts. I would have thought
update mysql.user
set password = '*E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB'
where user = 'ans';
would do the trick, but from my testing, that doesn't actually change the mysql login password.
mysql> create user 'ans'@'localhost' identified by 'foo';
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| ans | localhost | *F3A2A51A9B0F2BE2468926B4132313728C250DBF |
+------+-----------+-------------------------------------------+
mysql> update mysql.user set password = password('bar') where user = 'ans';
Query OK, 1 row affected (0.00 sec)
mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host | password |
+------+-----------+-------------------------------------------+
| ans | localhost | *E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB |
+------+-----------+-------------------------------------------+
mysql> quit
$ mysql -uans -pbar
ERROR 1045 (28000): Access denied for user 'ans'@'localhost' (using password: YES)
$ mysql -uans -pfoo
Welcome to the MySQL monitor. Commands end with ; or g.
passwords mysql hashing
passwords mysql hashing
asked Apr 15 '16 at 16:06
hymiehymie
901514
901514
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
When you hack the password into mysql.user
, you are supposed to run
mysql> FLUSH PRIVILEGES;
According to the MySQL Documentation on FLUSH
PRIVILEGES
Reloads the privileges from the grant tables in the mysql database.
The server caches information in memory as a result of GRANT, CREATE
USER, CREATE SERVER, and INSTALL PLUGIN statements. This memory is not
released by the corresponding REVOKE, DROP USER, DROP SERVER, and
UNINSTALL PLUGIN statements, so for a server that executes many
instances of the statements that cause caching, there will be an
increase in memory use. This cached memory can be freed with FLUSH
PRIVILEGES.
Now, you have to restart MySQL for the password to take affect.
add a comment |
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1065890%2fset-a-password-to-a-pre-hashed-value-in-mysql%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
When you hack the password into mysql.user
, you are supposed to run
mysql> FLUSH PRIVILEGES;
According to the MySQL Documentation on FLUSH
PRIVILEGES
Reloads the privileges from the grant tables in the mysql database.
The server caches information in memory as a result of GRANT, CREATE
USER, CREATE SERVER, and INSTALL PLUGIN statements. This memory is not
released by the corresponding REVOKE, DROP USER, DROP SERVER, and
UNINSTALL PLUGIN statements, so for a server that executes many
instances of the statements that cause caching, there will be an
increase in memory use. This cached memory can be freed with FLUSH
PRIVILEGES.
Now, you have to restart MySQL for the password to take affect.
add a comment |
When you hack the password into mysql.user
, you are supposed to run
mysql> FLUSH PRIVILEGES;
According to the MySQL Documentation on FLUSH
PRIVILEGES
Reloads the privileges from the grant tables in the mysql database.
The server caches information in memory as a result of GRANT, CREATE
USER, CREATE SERVER, and INSTALL PLUGIN statements. This memory is not
released by the corresponding REVOKE, DROP USER, DROP SERVER, and
UNINSTALL PLUGIN statements, so for a server that executes many
instances of the statements that cause caching, there will be an
increase in memory use. This cached memory can be freed with FLUSH
PRIVILEGES.
Now, you have to restart MySQL for the password to take affect.
add a comment |
When you hack the password into mysql.user
, you are supposed to run
mysql> FLUSH PRIVILEGES;
According to the MySQL Documentation on FLUSH
PRIVILEGES
Reloads the privileges from the grant tables in the mysql database.
The server caches information in memory as a result of GRANT, CREATE
USER, CREATE SERVER, and INSTALL PLUGIN statements. This memory is not
released by the corresponding REVOKE, DROP USER, DROP SERVER, and
UNINSTALL PLUGIN statements, so for a server that executes many
instances of the statements that cause caching, there will be an
increase in memory use. This cached memory can be freed with FLUSH
PRIVILEGES.
Now, you have to restart MySQL for the password to take affect.
When you hack the password into mysql.user
, you are supposed to run
mysql> FLUSH PRIVILEGES;
According to the MySQL Documentation on FLUSH
PRIVILEGES
Reloads the privileges from the grant tables in the mysql database.
The server caches information in memory as a result of GRANT, CREATE
USER, CREATE SERVER, and INSTALL PLUGIN statements. This memory is not
released by the corresponding REVOKE, DROP USER, DROP SERVER, and
UNINSTALL PLUGIN statements, so for a server that executes many
instances of the statements that cause caching, there will be an
increase in memory use. This cached memory can be freed with FLUSH
PRIVILEGES.
Now, you have to restart MySQL for the password to take affect.
answered Apr 22 '16 at 3:49
RolandoMySQLDBARolandoMySQLDBA
2,52511424
2,52511424
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1065890%2fset-a-password-to-a-pre-hashed-value-in-mysql%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown