# Docker MySQL 8.x Image (AMD64/ARM64)
The official MySQL repo image only supports AMD64 processors, and as Apple has introduced M1 chips (ARM64), I decided to build my own image so that dockerized apps that use MySQL can work without configuration changes on both the AMD64 and ARM64 processors.
This image inherits nearly all settings from the official docker [MySQL](https://hub.docker.com/_/mysql) image,
but the `mysql_native_password authentication` plugin is enabled by default.
The root user is also granted permission to log in from any host e.g `@%` by default , so you can connect with [tableplus](https://tableplus.com) or similar database managers. You can change the host by setting the env var `MYSQL_ROOT_HOST`.
The default username is `root` and password is `root`, however you can change by setting the new password in the env var `MYSQL_ROOT_PASSWORD`.
If you want it to create a database then set `MYSQL_DATABASE` with the database name. The image will also create a new user for you if you supply both a `MYSQL_USER` and `MYSQL_PASSWORD`. If you are creating both a user and database, then full permissions will be granted to the new user from any host.
### Docker Compose Service
To add as a service to your `docker-compose.yml`
```yaml
services:
db:
image: jamielsharief/mysql:latest
volumes:
- mysql-data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
ports:
- "3307:3306"
```
### Container
To work with a normal container, remember you need to setup volumes so data is persisted.
To start a MySQL container with the username `root` and password `root`
```
$ docker run -it -d -p 3306:3306 jamielsharief/mysql:latest
```
To change the root password
```
$ docker run -it -p 3306:3306 -e MYSQL_ROOT_PASSWORD=foo jamielsharief/mysql:latest
```
To create a database
```
$ docker run -it -p 3306:3306 -e MYSQL_DATABASE=application jamielsharief/mysql:latest
```
To create a user you must supply both a username and password
```
$ docker run -it -p 3306:3306 -e MYSQL_USER=jon -e MYSQL_PASSWORD=secret jamielsharief/mysql:latest
```
If you are creating a user and a database, full permissions will be granted for that
user on that database.
Here is a full example
```
$ docker run -it -p 3306:3306 -e MYSQL_ROOT_PASSWORD=foo -e MYSQL_USER=roger -e MYSQL_PASSWORD=beck -e MYSQL_DATABASE=application jamielsharief/mysql:latest
```
## Resources
- [Github](https://github.com/jamielsharief/docker-mysql)
- [Docker Hub](https://hub.docker.com/r/jamielsharief/mysql)
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Docker MySQL 8.x 镜像 (AMD64/ARM64) 官方 MySQL 存储库映像仅支持 AMD64 处理器,并且由于 Apple 推出了 M1 芯片 (ARM64),我决定构建自己的映像,以便使用 MySQL 的 dockerized 应用程序可以在 AMD64 和 ARM64 处理器上运行而无需更改配置。 该镜像几乎继承了官方mysql_native_password authentication 镜像的所有设置,但默认启用了mysql_native_password authentication插件。 root 用户还被授予从任何主机登录的权限,例如默认情况下@% ,因此您可以连接或类似的数据库管理器。 您可以通过设置环境MYSQL_ROOT_HOST来更改主机。 默认用户名是root ,密码是root ,但是您可以通过在环境MYSQL_ROOT_PASSWOR
资源详情
资源评论
资源推荐
收起资源包目录
docker-mysql-main.zip (8个子文件)
docker-mysql-main
config
my.cnf 161B
conf.d
docker.cnf 137B
docker-entrypoint.sh 2KB
.github
workflows
build.yml 853B
Dockerfile 766B
LICENSE.md 11KB
README.md 2KB
building.md 803B
共 8 条
- 1
吾自行
- 粉丝: 61
- 资源: 4670
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0