sudo docker exec -it mysql5 bash mysql -uroot -pyour_root_passwd
开启远程连接服务
mysql> grant all privileges on *.* to root@'%' identified by 'your_root_passwd' with grant option;
mysql> flush privilesges;
ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '12345678';
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;
修改密码
update mysql.user set authentication_string=password('新密码') where user='root' ;
flush privileges;
PS
# 用户信息
select host,user,plugin,authentication_string from mysql.user;
# 时区
show variables like '%time_zone%';
# 变量
SHOW VARIABLES WHERE Variable_name LIKE 'character_set_%' OR Variable_name LIKE 'collation%';
# 更改数据库编码
ALTER DATABASE caitu99 CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
# 更改表编码
ALTER TABLE TABLE_NAME CONVERT TO CHARACTER SET utf8mb4 COLLATEutf8mb4_general_ci;