CREATE USER 'root'@'192.168.1.%' IDENTIFIED BY 'root';
mysql 8.0 以上...
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
mysql 5.5 :
update user set password=password('123') where user='root' and host='localhost';
或 update user set password=password('123') where user='root' ;
GRANT ALL privileges ON *.* TO 'root'@'192.168.1.%'; flush PRIVILEGES;
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
设置密码不过期
alter user 'root'@'localhost' password expire never;
如果是 Mysql 8.0 ,请将 三句话 分开来写!! 也就是 3 句话 不能在 同一个事务中执行!!!
CREATE USER 'root'@'192.168.0.%' IDENTIFIED BY 'root'; GRANT ALL privileges ON *.* TO 'root'@'192.168.1.%';flush PRIVILEGES;