1.创建网络。以供其他docker访问
docker network create backend
2.启动一个空mysql
docker run -d --name mysql -p 3306:3306 --net=backend --restart always --privileged=true -e MYSQL_USER="root" -e MYSQL_PASSWORD="123456" -e MYSQL_ROOT_PASSWORD="123456" -e character-set-server=utf8 -e collation-server=utf8_general_ci -v=/home/pi/program/libs/mysql/my.cnf:/etc/my.cnf -v=/home/pi/program/libs/mysql/data:/var/lib/mysql -d ibex/debian-mysql-server-5.7
3.复制my.cnf中的
cp /etc/mysql/mysqld.cnf.disabled /var/lib/mysql
mv mysqld.cnf.disabled my.cnf
4.1.修改部分内容
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
4.2 修改网卡,供远程访问
bind-address = 0.0.0.0
5。再次启动
docker run -d --name mysql -p 3306:3306 --net=backend --restart always --privileged=true -e MYSQL_USER="root" -e MYSQL_PASSWORD="123456" -e MYSQL_ROOT_PASSWORD="123456" -e character-set-server=utf8 -e collation-server=utf8_general_ci -v=/home/pi/program/libs/mysql/my.cnf:/etc/my.cnf -v=/home/pi/program/libs/mysql/data:/var/lib/mysql -d ibex/debian-mysql-server-5.7
6.授权root远程访问
grant all privileges on *.* to 'root'@'%' identified by '123456';
FLUSH PRIVILEGES
树莓派4B从0安装mysql的docker版本
最新推荐文章于 2023-11-15 11:42:45 发布