首页 > 数据库 >mac-docker安装使用mysql

mac-docker安装使用mysql

时间:2023-02-05 13:22:39浏览次数:89  
标签:mini frantichow FrantiChowdeMac server mac mysql docker

参考:https://blog.csdn.net/m0_67402588/article/details/126075186

1、下载镜像,注意这里要下载适配了arm架构的镜像源

docker pull mysql/mysql-server

2、创建容器

docker run --name mysql-local -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql/mysql-server

3、进入到docker容器中修改连接权限,否则只能本地连接

docker exec -it mysql-local bash
# 进入mysql命令行
mysql -uroot -p123456
# 授权
use mysql;
update user set host = "%" where user='root';
# 刷新权限
flush privileges;

实操

frantichow@FrantiChowdeMac-mini homebrew % docker pull mysql/mysql-server


Using default tag: latest
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
frantichow@FrantiChowdeMac-mini homebrew %
frantichow@FrantiChowdeMac-mini homebrew %
frantichow@FrantiChowdeMac-mini homebrew % systemctl start docker.service
zsh: command not found: systemctl
frantichow@FrantiChowdeMac-mini homebrew % docker pull mysql/mysql-server

Using default tag: latest
latest: Pulling from mysql/mysql-server
latest: Pulling from mysql/mysql-server
022417830bcf: Pull complete
fe10b20dcdae: Pull complete
624f2f22548b: Pull complete
0eb07ea8ad2a: Pull complete
8b517dfb74ad: Pull complete
ebef84d68e30: Pull complete
604975d7252e: Pull complete
Digest: sha256:d6c8301b7834c5b9c2b733b10b7e630f441af7bc917c74dba379f24eeeb6a313
Status: Downloaded newer image for mysql/mysql-server:latest
docker.io/mysql/mysql-server:latest
frantichow@FrantiChowdeMac-mini homebrew % cd
frantichow@FrantiChowdeMac-mini ~ % ls
Desktop		Downloads	Movies		Pictures	Sunlogin	configfile	log
Documents	Library		Music		Public		Sunlogin Files	docker-hue-4.10
frantichow@FrantiChowdeMac-mini ~ % vim docker_mysql.sh
frantichow@FrantiChowdeMac-mini ~ % docker images
REPOSITORY           TAG       IMAGE ID       CREATED        SIZE
mysql/mysql-server   latest    423da140c8c0   2 weeks ago    507MB
gethue/hue           latest    9045fd343f92   4 months ago   1.8GB
frantichow@FrantiChowdeMac-mini ~ %
frantichow@FrantiChowdeMac-mini ~ %
frantichow@FrantiChowdeMac-mini ~ %
frantichow@FrantiChowdeMac-mini ~ % sh docker_mysql.sh
91426d7b0bdc734e690247d861390f1390adbb13c92ea1ceb6f9d9d26e26c5c3
frantichow@FrantiChowdeMac-mini ~ % docker ps
CONTAINER ID   IMAGE                COMMAND                  CREATED         STATUS                            PORTS                                     NAMES
91426d7b0bdc   mysql/mysql-server   "/entrypoint.sh mysq…"   3 seconds ago   Up 2 seconds (health: starting)   0.0.0.0:3306->3306/tcp, 33060-33061/tcp   mysql-local
frantichow@FrantiChowdeMac-mini ~ % docker exec -it mysql-local bash
bash-4.4# mysql -uroot -p123456
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 8
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, 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> #
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set host = "%" where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> #
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql>

标签:mini,frantichow,FrantiChowdeMac,server,mac,mysql,docker
From: https://www.cnblogs.com/frantichow/p/17093236.html

相关文章

  • 解决MacOS13 Ventura 经常性的出现xxx软件不可用的问题
    解决MacOS13Ventura经常性的出现xxx软件不可用的问题前提型号:Macbookpro14(M1pro)问题:在更新MacOS13Ventura系统经常会出现软件不可用的现象尝试过很多种命令行......
  • macOS M1安装HomeBrew
    macOSM1安装HomeBrewHomebrew是什么?Homebrew是一款MacOS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理......
  • docker一次性打包所有镜像
    $dockerimagesREPOSITORYTAGIMAGEIDCREATEDSIZEregistry.aliyuncs.com/google_containers/kube-......
  • mac m1 安装php扩展
    安装xdebug进入https://pecl.php.net/package/Xdebug选择对应的版本下载php8.0下载xdebug-3.2.0.tgz解压tar-zxvfxdebug-3.2.0.tgz进入解压目录执行phpi......
  • mac笔记本查看cpu详细参数命令
    mac笔记本查看cpu详细参数命令sysctlmachdep.cpu.brand_string以上的结果显示Intel(R)Core(TM)[email protected]我的笔记本的cpu是i5第五代产品......
  • [Docker] Remove all containers and images
    TocleanupDockerimagesandcontainers,youcanusethefollowingcommandsintheterminal:Removeallcontainers:dockerrm$(dockerps-a-q)Removeall......
  • docker rabbit启动失败,报错:erlang.cookie must be accessible by owner only
    环境:操作系统:Centos7、docker执行:dockerstartmall-rabbit现象:容器启动数秒后,启动失败查看失败原因:dockerlogs mall-rabbit  解析Json发现问题指向Cookie......
  • docker使用
    docker使用1.安装docker安装docker源https://developer.aliyun.com/mirror/---------------------------安装步骤centos7------------------------------#step......
  • Docker入门
    Docker入门一、Docker为什么会出现此外,Docker是基于Go开发的。二、虚拟化技术和容器化技术的对比(1)虚拟化技术的缺点·资源占用十分多·冗余步骤多·启动很慢(2)容......
  • Mac上Homebrew常用命令
    Mac上Homebrew常用命令官方网址https://brew.sh/常用命令安装(官方方法)/bin/bash-c"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/HEAD/inst......