Derzeit verwendete Benutzer und Host:
mysql> select USER(); +----------------+ | USER() | +----------------+ | root@localhost | +----------------+ 1 row in set (0.00 sec)
Benutzer hinzufügen
Frühere Versionen von MySQL5 haben INSERT direkt verwendet, um MySQL-Benutzer in die MySQL-Tabelle einzufügen. Dieser Vorgang kann nach MySQL5 nicht mehr ausgeführt werden
mysql> insert into mysql.user(Host,User,Password) values('localhost','test_user',password('123123')); ERROR 1062 (23000): Duplicate entry 'localhost-test_user' for key 'PRIMARY'
mysql> GRANT all privileges ON table1.* TO 'test_user'@'localhost' IDENTIFIED BY '123123' WITH GRANT OPTION; Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
mysql> drop user 'test_user'@'localhost';
mysql> SHOW GRANTS; +----------------------------------------------------------------------------------------------------------------------------------------+ | Grants for root@localhost | +----------------------------------------------------------------------------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '\*E56A114692FE0DE073F9A1DD68A00EEB9703F3F1' WITH GRANT OPTION | | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION | +----------------------------------------------------------------------------------------------------------------------------------------+
mysql> show grants for 'test_user'@'localhost' +------------------------------------------------------------------------------------------------------------+ | Grants for test_user@localhost | +------------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'test_user'@'localhost' IDENTIFIED BY PASSWORD '\*E56A114692FE0DE073F9A1DD68A00EEB9703F3F1' | | GRANT ALL PRIVILEGES ON table1.* TO 'test_user'@'localhost' WITH GRANT OPTION | +------------------------------------------------------------------------------------------------------------+
mysql> rename user 'test_user'@'localhost' to 'bb'@'localhost';
mysql> SET PASSWORD FOR 'test_user'@'localhost' = PASSWORD('123456');
/usr/bin$ mysqladmin -utest_user -p123456 password 123123 mysqladmin: Can't turn off logging; error: 'Access denied; you need (at least one of) the SUPER privilege(s) for this operation'
mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> update user set PASSWORD = PASSWORD('123123') where user = 'test_user'; Query OK, 1 row affected (0.04 sec) Rows matched: 1 Changed: 1 Warnings: 0
MySQL-Tutorial“
Das obige ist der detaillierte Inhalt vonEinführung in Kenntnisse im Zusammenhang mit der MySQL-Benutzerverwaltung. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!