# mysql -uroot -p #進入數據庫
> use mysql;#進入數據庫
> select host, user, authentication_string, plugin from user;#查看用戶信息
> GRANT ALL ON *.* TO 'root'@'%';#授權root用戶可以遠程登陸
> flush privileges;#立即生效
> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';#修改root用戶密碼
> FLUSH PRIVILEGES;#立即生效
> exit;#退出
# service mysql restart#重啟mysql服務