version: '3' services: mysql: container_name: mysql image: mysql:latest network_mode: "host" restart: always environment: - TZ=Asia/Shanghai - MYSQL_ROOT_PASSWORD=123456 ports: - "3306:3306" volumes: - /home/data/pubserver/mysql/conf/my.cnf:/etc/mysql/my.cnf - /home/data/pubserver/mysql/logs:/logs - /home/data/pubserver/mysql/data:/var/lib/mysql
mysql直接启动也是不行的,这里需要提前准备my.cnf文件,可以直接创建本文件,然后把下面的内容复制进去.
[mysqld] # 根据需求修改端口号:3306 port=3306 datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock transaction-isolation = READ-COMMITTED # Disabling symbolic-links is recommended to prevent assorted security risks; # to do so, uncomment this line: symbolic-links = 0 key_buffer_size = 32M max_allowed_packet = 32M thread_stack = 256K thread_cache_size = 64 query_cache_limit = 8M query_cache_size = 64M query_cache_type = 1 max_connections = 550 #expire_logs_days = 10 #max_binlog_size = 100M #log_bin should be on a disk with enough free space. #Replace '/var/lib/mysql/mysql_binary_log' with an appropriate path for your #system and chown the specified folder to the mysql user. log_bin=/var/lib/mysql/mysql_binary_log #In later versions of MySQL, if you enable the binary log and do not set #a server_id, MySQL will not start. The server_id must be unique within #the replicating group. server_id=1 binlog_format = mixed read_buffer_size = 2M read_rnd_buffer_size = 16M sort_buffer_size = 8M join_buffer_size = 8M # InnoDB settings innodb_file_per_table = 1 innodb_flush_log_at_trx_commit = 2 innodb_log_buffer_size = 64M innodb_buffer_pool_size = 4G innodb_thread_concurrency = 8 innodb_flush_method = O_DIRECT innodb_log_file_size = 512M [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid sql_mode=STRICT_ALL_TABLES
这个配置文件只保证包mysql启动起来,具体需要什么配置可以自行配置解决。
还没有评论,来说两句吧...