随笔 - 43  文章 - 0  评论 - 1  阅读 - 80532

docker安装mysql8

一、开始安装

复制代码
# 新建挂载目录
mkdir -p /opt/docker/mysql/data mkdir -p /opt/docker/mysql/conf

vim /opt/docker/mysql/conf/my.cnf

[root@centos01 mysql]# cd conf/
[root@centos01 conf]# ls
my.cnf
[root@centos01 conf]# cat my.cnf
[client]
default-character-set=utf8mb4

[mysql]
default-character-set=utf8mb4

[mysqld]

character-set-server=utf8
collation-server=utf8_general_ci
lower_case_table_names=1
init_connect='SET NAMES utf8'
max_connections=5000
wait_timeout=20000
max_user_connections=5000
max_allowed_packet=128M
thread_stack=262144

#不区分大小写 很重要

#lower_case_table_names=1



# 启动
docker run --restart=always --privileged=true --name mysql8 \
-v /datah/mydata/mysql/conf:/etc/mysql/conf.d \
-v /datah/mydata/mysql/data:/var/lib/mysql \
-p 3307:3306 -e MYSQL_ROOT_PASSWORD='123456' -d mysql


复制代码

 

二、修改配置 改密码

复制代码
#进入mysql8容器
docker exec -it mysql8 bash

# 如果看到两个root用户,删除一个即可。

opyright (c) 2000, 2024, 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> 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> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| root | % |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)

mysql>

# 改密码, 重要的是 mysql_native_password

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

 

复制代码

 

posted on   wuyicode  阅读(800)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示