mysql相关记录

Mysql修改临时密码

Mysql 5.7默认安装之后root是有密码的。

获取MySql临时密码

grep 'temporary password' /var/log/mysqld.log

登录并修改密码

mysql -u root -p

三种修改密码的方式

mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
mysql> alter user 'root'@'localhost' identified by '123';
mysql> set password for 'root'@'localhost'=password('123');

设置完成之后刷新权限

mysql> flush privileges;

修改ip权限

grant all privileges on *.* to 'root'@'192.168.0.1' identified by '123456';

如果想给所有ip都赋予权限,则这样

grant all privileges on *.* to 'root'@'%' identified by '123456';

使授权立即生效

flush privileges;