【docker】mysql禁用ssl

mysql禁用ssl

最近用docker启动了mysql,但是my.cnf配置文件不知道放在哪里,用的最新的版本

用django连接的mysql

sh 复制代码
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 25, in <module>
    main()
  File "manage.py", line 21, in main
    execute_from_command_line(sys.argv)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\core\management\__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\core\management\base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\core\management\base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\core\management\commands\migrate.py", line 75, in handle
    self.check(databases=[database])
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\core\management\base.py", line 423, in check
    databases=databases,
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\core\checks\registry.py", line 76, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\core\checks\database.py", line 13, in check_database_backends
    issues.extend(conn.validation.check(**kwargs))
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\db\backends\mysql\validation.py", line 9, in check
    issues.extend(self._check_sql_mode(**kwargs))
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\db\backends\mysql\validation.py", line 13, in _check_sql_mode
    if not (self.connection.sql_mode & {'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES'}):
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\db\backends\mysql\base.py", line 405, in sql_mode
    sql_mode = self.mysql_server_data['sql_mode']
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\db\backends\mysql\base.py", line 366, in mysql_server_data
    with self.temporary_connection() as cursor:
  File "E:\python3.7\lib\contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\db\backends\base\base.py", line 603, in temporary_connection
    with self.cursor() as cursor:
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\utils\asyncio.py", line 33, in inner
    return func(*args, **kwargs)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor
    return self._cursor()
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\db\backends\base\base.py", line 235, in _cursor
    self.ensure_connection()
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\utils\asyncio.py", line 33, in inner
    return func(*args, **kwargs)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
    self.connect()
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\db\utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\db\backends\base\base.py", line 219, in ensure_connection
    self.connect()
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\utils\asyncio.py", line 33, in inner
    return func(*args, **kwargs)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\db\backends\base\base.py", line 200, in connect
    self.connection = self.get_new_connection(conn_params)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\utils\asyncio.py", line 33, in inner
    return func(*args, **kwargs)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\django\db\backends\mysql\base.py", line 234, in get_new_connection
    connection = Database.connect(**conn_params)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\MySQLdb\__init__.py", line 84, in Connect
    return Connection(*args, **kwargs)
  File "E:\code\stock-analys-web\stock-analys-web\venv\lib\site-packages\MySQLdb\connections.py", line 179, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2026, 'SSL connection error: unknown error number')

百度了下,需要加个参数skip_ssl

配置在config目录下,映射到/etc/mysql/conf.d, 需要在config目录下创建my.cnf,这样才能指定运行修改配置的mysql,这里需要禁用ssl

ini 复制代码
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
skip-host-cache
skip-name-resolve
datadir=/var/lib/mysql
socket=/var/run/mysqld/mysqld.sock
secure-file-priv=/var/lib/mysql-files
user=mysql
# 需要禁用ssl
skip_ssl

pid-file=/var/run/mysqld/mysqld.pid
[client]
socket=/var/run/mysqld/mysqld.sock

!includedir /etc/mysql/conf.d/

docker-compose mysql的配置

yaml 复制代码
version: '3'
services:
  mysql:
    image: mysql
    restart: always
    container_name: mysql
    environment:
      MYSQL_ROOT_PASSWORD: password
      TZ: Asia/Shanghai
    ports:
      - 3306:3306
    volumes:
      - /root/docker-compose/mysql/data:/var/lib/mysql
      - /root/docker-compose/mysql/config:/etc/mysql/conf.d
    command:
      --max_connections=1000
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --default-authentication-plugin=mysql_native_password
相关推荐
gsls2008083 小时前
docker打包nginx版wordpress
nginx·docker·wordpress
DC_BLOG3 小时前
Mysql-DDL语句
服务器·数据库·mysql
努力遇见美好的生活4 小时前
Mysql每日一题(行程与用户,困难※)
android·数据库·mysql
卫生纸不够用4 小时前
远程链接mysql步骤
数据库·mysql
Hoper.J5 小时前
用两行命令快速搭建深度学习环境(Docker/torch2.5.1+cu118/命令行美化+插件),包含完整的 Docker 安装步骤
人工智能·深度学习·docker
液态不合群5 小时前
Mysql篇-三大日志
数据库·mysql
Nue.js6 小时前
Docker中最常用的一些命令
docker·容器·eureka
小徍6 小时前
MySQL 8.0特性-自增变量的持久化
数据库·mysql
冰红茶兑滴水7 小时前
MySQL 表的约束
数据库·mysql
小五Z7 小时前
MySql--增删改查表设计总结
数据结构·数据库·mysql