一直以来都想直接安逸的在鲲鹏上搞mysql,终于搞通了


vi Dockerfile

#!/bin/bash

FROM swr.cn-north-4.myhuaweicloud.com/hwstaff_imagemarket/mysql-onlinelab:5.7.30-arm64v8

vi build

#!/bin/sh

docker build -t docker-mysql:5.7.30-armv8 .

chmod u+x build


vi run

#!/bin/bash

cmd=(
    docker run
    -dit
    --name mysql57-1
    --hostname=mysql57
    --privileged=true
    -p 3306:3306
    -e MYSQL_ROOT_PASSWORD=xxx
    docker-mysql:5.7.30-armv8
    /usr/sbin/init
)

"${cmd[@]}"

chmod u+x run


  • ./build
  • ./run
  • docker ps
  • docker logs container-ID
  • docker exec -it container-ID bash
  • mysql -uroot -p
  • ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
  • GRANT ALL PRIVILEGES ON *.* TO 'demo'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
  • flush privileges;
  • SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

然后通过远程连接数据库的工具连接测试


打完收工!