linux下添加mysql用户并授权

时间:2021-04-19 15:52:05

-------------------
暂停mysql
service mysqld stop

忘记密码修改流程
1,修改mysql配置文件 /etc/my.cnf,在[mysqld]下添加一行skip-grant-tables
2, 重启mysql service mysqld restart
3, mysql -u root -p
不用输入密码就直接进入了mysql

mysql修改密码
use mysql
update user set Password = password('nf123456') where User = 'root';

添加用户
CREATE USER 'www5'@'%' IDENTIFIED BY 'nf123456';

给用户授权
GRANT ALL ON *.* TO 'www5'@'%';