У меня есть несколько тысяч пользователей MySQL весь набор для предоставления доступа от определенного хоста. Проблема состоит в том, что теперь я собираюсь иметь две машины (больше в будущем), который должен будет использовать ту же учетную запись для доступа к каждой из их баз данных.
Я хотел бы быстрое и легкое (как автоматизировано как возможные) способ пробежать и изменить часть, относящуюся к хосту каждой учетной записи пользователя для установки подстановочному знаку внутренней сети. Например:
'Багси' 'internalfoo' имеет доступ к DB 'Багси'.
Я хочу теперь предоставить доступ Багси отовсюду на внутренней сети
'Багси' '10.0.0. %' имеет доступ к DB 'Багси'.
I haven't had to do this, so take this with a grain of salt and a big helping of "test, test, test".
What happens if (in a safe controlled test environment) you directly modify the Host
column in the mysql.user
and probably mysql.db
tables? (E.g., with an update
statement.) I don't think MySQL uses the user's host as part of the password encoding (the PASSWORD
function doesn't suggest it does), but you'll have to try it to be sure. You may need to issue a FLUSH PRIVILEGES
command (or stop and restart the server).
For some storage engines (MyISAM, for instance), you may also need to check/modify the .frm
file any views that user has created. The .frm
file stores the definer, including the definer's host. (I have had to do this, when moving databases between hosts where there had been a misconfiguration causing the wrong host to be recorded...)