【三】pig4cloud项目一键build -- Mysql创建新用户,并外网访问
Mysql 默认用户root
是禁止外网访问的,而且使用root
外网访问权限太大,不安全, 而且pig4cloud
程序里面默认配置的是root
,那这里我们把root
用户作为程序运行的账户,我们新创建一个developer
账户作为开发人员使用的账户。
进入容器,并切换mysql数据库#
# 1、进入容器
docker exec -it mysql /bin/bash
# 2、容器内使用root登录mysql, 账户密码默认都是root
bash-4.4# mysql -u root -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 708
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
创建账户#
指定mysql_native_password
,否则在用native登录的时候会提示caching_sha2_password,需要再去修改用户配置
# 创建一个新用户
create user 'developer'@'%' identified with mysql_native_password by '123456';
授权#
这里为了图方便,开放了所有权限,正常情况下,是按照账户角色开对应的数据库权限
# 授予所有权限
grant all on *.* to developer@'%';
* :具体的可参考
https://blog.csdn.net/wwppp987/article/details/123983250
刷新配置#
# 刷新
FLUSH PRIVILEGES;
客户端连接测试#
作者:Darren
出处:https://www.cnblogs.com/jesn/p/16502191.html
版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现