Windows
my.ini
[mysqld]
port = 3000
basedir = D:\Program Files\mysql-8.0.31
datadir = D:\Program Files\mysql-8.0.31\data
secure-file-priv = NULL
# user-defined
skip-name-resolve
character-set-server = utf8mb4
default-time-zone = '+8:00'
innodb_rollback_on_timeout = 'ON'
max_connections = 1000
innodb_lock_wait_timeout = 500
shared-memory
default-authentication-plugin = mysql_native_password
general_log = 1
slow_query_log = 1
log-error = D:\Program Files\mysql-8.0.31\logs\error.log
log-bin = mysql-bin
# log_replica_updates
user = mysql
sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
# cert
# ssl-ca = "D:\Program Files\mysql-8.0.19\data\mysql-server.crt"
# ssl-cert = "D:\Program Files\mysql-8.0.19\data\mysql-server.crt"
# ssl-key = "D:\Program Files\mysql-8.0.19\data\mysql-server.key"
connect_timeout = 10
interactive_timeout = 28800
wait_timeout = 28800
# validate_password.length = 10
# validate_password.number_count = 2
# plugin-load-add = # connection_control.dll
# connection-control = FORCE
# connection-control-failed-login-attempts = FORCE
# connection_control_min_connection_delay = 1000
# connection_control_max_connection_delay = 86400
# connection_control_failed_connections_threshold = 3
# innodb_buffer_pool_size = 4G
# innodb_log_buffer_size = 256M
# innodb_log_file_size = 1G
# innodb_write_io_threads = 16
# innodb_flush_log_at_trx_commit = 0
# innodb_doublewrite = 0
# Row size too large
# innodb_strict_mode=0
[mysql]
local_infile = 0
[client]
port=3000
default-character-set=utf8mb4
install
- create
my.ini
- create
logs
- create app
# init
bin\mysqld.exe --initialize --console
# install service
bin\mysqld.exe install mysql8
# start service
net start mysql8
# root password `logs\error.log`
# stop service
net stop mysql8
# delete service
sc.exe delete mysql8
# login
bin\mysql.exe -uroot -P3000 -p
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Linux
my.cnf
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv = NULL
# user-defined
skip-name-resolve
character-set-server = utf8mb4
default-time-zone = '+8:00'
innodb_rollback_on_timeout = 'ON'
max_connections = 1000
innodb_lock_wait_timeout = 500
default-authentication-plugin = mysql_native_password
lower_case_table_names = 1
general_log = 1
slow_query_log = 1
log-error = /logs/error.log
log-bin = mysql-bin
log_slave_updates
user = mysql
sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
# password policy
# validate_password.length = 10
# validate_password.number_count = 2
# login failed
# plugin-load-add = connection_control.so
# connection-control = FORCE
# connection-control-failed-login-attempts = FORCE
# connection_control_min_connection_delay = 1000
# connection_control_max_connection_delay = 86400
# connection_control_failed_connections_threshold = 3
[mysql]
local_infile = 0
docker-compose.yml
services:
mysql:
container_name: mysql8.0
image: mysql:8.0.15
restart: always
environment:
- MYSQL_ROOT_PASSWORD=123456
volumes:
- /etc/localtime:/etc/localtime:ro
- ./conf/my.cnf:/etc/mysql/my.cnf6644
- ./data:/var/lib/mysql
- ./logs:/logs
logging:
driver: "json-file"
options:
max-size: "100m"
install
- create
docker-compose.yml
- create
logs
- create
conf/my.cnf
- change permissions
chmod -R 777 ./logs
chmod 644 conf/my.cnf
docker-compose up -d
docker exec -it mysql8.0 bash
mysql_secure_installation