mysql> SELECT User, Host, Password FROM mysql.user;
添加新用户 - 以下方式适用于 5.7 以前的版本
1
mysql> INSERT INTO mysql.user (User,Host,Password) VALUES('demouser','localhost',PASSWORD('demopassword'));
添加新用户 - 以下方式适用于 5.7 以后的版本
1 2 3
mysql> GRANT USAGE ON *.* TO 'zhangyanxi'@'localhost' IDENTIFIED BY 'yanxi312' WITH GRANT OPTION; mysql> GRANT ALL ON *.* TO 'zhangyanxi'@'localhost'; ======> 给用户授权 mysql> flush privileges;
给用户授权相关
1 2 3
mysql> GRANT ALL PRIVILEGES ON demodb.* to demouser@localhost; GRANT SELECT, INSERT ON *.* TO 'zhangyanxi'@'localhost'; GRANT ALL ON *.* TO 'zhangyanxi'@'%';