![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I come from the Postgres world where one user has one password[1] and pg_hba.conf decides which hosts that user may connect from. [1] OK, it can get funky - but for the sake of argument, let's assume so... I'm not a MySQL buff but I have inherited a few: *Seems* to be the case that a password belongs to the pattern "user@somewhere" rather than just "user". Correct me if I'm wrong - but when I did some extra grants to allo a user to connect from some extra client hosts, the new user was passwordless(!) (the original user@somblah did require a password. If I've got the right end of the stick, how do I grant access to a user to a database (and tables etc etc) without having to specify a password - ie to have the system use only one password? I did RTFM but as I haven't found a tome "MySQL for PostgreSQL admins" I haven't seen a really clear explanation of how MySQL authentication works. Any comments received with thanks! Cheers Tim |
#3
| |||
| |||
|
|
You don't. If you want them to have to use a password, you need to specify the password in the grant for that host. |
|
MySQL is not PostGres and it's authentication works differently. And DB2, Oracle and SQL Server each work differently, also. |
|
Now, with that said, you *could* just insert the row into the mysql.users table, taking the password from an existing row for that user. But you have to be very careful and know what you're doing when dealing with the mysql.xxx tables - you can easily leave yourself with an non-working system. |

#4
| |||
| |||
|
|
Jerry Stuckle wrote: Hi Jerry, You don't. If you want them to have to use a password, you need to specify the password in the grant for that host. Right - so I was right in thinking that was how it was behaving... MySQL is not PostGres and it's authentication works differently. And DB2, Oracle and SQL Server each work differently, also. Yep. Now, with that said, you *could* just insert the row into the mysql.users table, taking the password from an existing row for that user. But you have to be very careful and know what you're doing when dealing with the mysql.xxx tables - you can easily leave yourself with an non-working system. I think I will have to do that - as a sysadmin, I don't want to be calling the user for their password everytime this happens (often). Sounds like a handy stored procedure could be written to do this - I'll look into that. Longer term, I'll probably rationalise the whole thing so accounts have access from entire sub-networks instead of host by host. Pity they didn't have a nice option for "dup the password" on grant ![]() Thanks for your help. Cheers, Tim |
#5
| |||
| |||
|
|
I'm not a MySQL buff but I have inherited a few: *Seems* to be the case that a password belongs to the pattern "user@somewhere" rather than just "user". |
|
Correct me if I'm wrong - but when I did some extra grants to allo a user to connect from some extra client hosts, the new user was passwordless(!) (the original user@somblah did require a password. |
#6
| |||
| |||
|
|
Tim Watts <tw (AT) dionic (DOT) net> wrote: I'm not a MySQL buff but I have inherited a few: *Seems* to be the case that a password belongs to the pattern "user@somewhere" rather than just "user". |
|
In MySQL a user specification always has the form username (AT) hostname (DOT) Both parts can contain wildcards. And the host part can also make use of numerical ip address ranges (by using a net mask). http://dev.mysql.com/doc/refman/5.1/...unt-names.html Correct me if I'm wrong - but when I did some extra grants to allo a user to connect from some extra client hosts, the new user was passwordless(!) (the original user@somblah did require a password. Short: you are looking for the NO_AUTO_CREATE_USER SQL mode: http://dev.mysql.com/doc/refman/5.1/en/server-sql- mode.html#sqlmode_no_auto_create_user Long: if you execute a GRANT statement for a not yet existing user, then this user is created automatically. If your GRANT statement lacks a 'IDENTIFIED BY' clause, then this new user will have no password. The abovementioned SQL mode modifies the behavior of GRANT, such that it will never create a new user without a password. |
|
You still can create a new user and GRANT privileges at once, but then the GRANT statement must specify a nonempty password. Alternatively you can use CREATE USER first and then GRANT to add permissions. GRANT will never be a problem if you add permissions to existing users. XL |
#7
| |||
| |||
|
|
Now, with that said, you *could* just insert the row into the mysql.users table, taking the password from an existing row for that user. But you have to be very careful and know what you're doing when dealing with the mysql.xxx tables - you can easily leave yourself with an non-working system. I think I will have to do that - as a sysadmin, I don't want to be calling the user for their password everytime this happens (often). Sounds like a handy stored procedure could be written to do this - I'll look into that. |
|
Longer term, I'll probably rationalise the whole thing so accounts have access from entire sub-networks instead of host by host. Pity they didn't have a nice option for "dup the password" on grant ![]() |
#8
| |||
| |||
|
Pity they didn't have a nice option for "dup the password" on grant ![]() In a way, they do. CREATE USER ... IDENTIFIED BY PASSWORD '*94284756DEADBEEF02856778236554784848' ... ... The second form allows you to copy the encrypted password from one user entry to another. You can select it from the user table, then cut-and-paste it into a create user command. You should never have to call a user and ask for their password. Although writing on the mysql database with direct SQL queries can mess up your system, just reading it is relatively harmless |
![]() |
| Thread Tools | |
| Display Modes | |
| |