centos 版本 CentOS Linux release 7.5.1804 (Core)
内核版本: 3.10.0-862.el7.x86_64
下载最新版mysql
docker pull mysql
启动镜像
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=woshimima -d mysql
进入命令
docker exec -it mysql /bin/bash
连接数据库
mysql -uroot -p woshimima
查看编码格式
show variables like "%char%";
utf8mb4 代表可以添加emoji ,所以要修改格式
set character_set_client = utf8mb4; set character_set_connection = utf8mb4; set character_set_database = utf8mb4; set character_set_filesystem = utf8mb4; set character_set_results = utf8mb4; set character_set_server = utf8mb4;
FLUSH PRIVILEGES;
这个只是暂时修改了编码格式,重启了mysql还是变回了原来的样子。气不气?要去文件里修改配置,
#/etc/mysql/conf.d/mysql.cnf 这个就是文件位置,替换一下 docker cp D:
ginx-1.13.12conf.dmysql.cnf 193290698eb9:/etc/mysql/conf.d/mysql.cnf
[client]
#设置客户端编码
default-character-set=utf8mb4
这样就修改完成了,重启进入查看一下
完美
退出。重新进入 连接数据库 修改root密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'woshimima';
FLUSH PRIVILEGES;
创建表
create database weiqinke;
创建用户
CREATE USER weiqinke IDENTIFIED BY 'woshimima';
给weiqinke 这个表加一个用户并刷新权限
grant all privileges on weiqinke.* to 'weiqinke'@'%' with grant option;
flush privileges;
删除Root的远程权限
delete from user where user='root'and host='%';
此时结束了。
下面是配置,此项配置占用了382M内存,原始配置占用了462M,下降了大约80M内存,本身就是2G,暂时还能用,后期看到好的参数,再进行调优吧
[mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql secure-file-priv= NULL innodb_buffer_pool_size=1000000000 # 按事物刷盘,刷日志 innodb_flush_log_at_trx_commit=1 # 脏页占innodb_buffer_pool_size的比例时,触发刷脏页到磁盘 # 25%~50% innodb_max_dirty_pages_pct=30 # 后台进程最大IO性能指标 # 默认200,如果SSD,调整为5000~20000 innodb_io_capacity=100 # 全量日志建议关闭 # 默认关闭 general_log=0 table_open_cache=2000 tmp_table_size=12M thread_cache_size=10 myisam_max_sort_file_size=1G myisam_sort_buffer_size=15M key_buffer_size=8M read_buffer_size = 30K read_rnd_buffer_size=256K innodb_flush_log_at_trx_commit=1 innodb_log_buffer_size=1M innodb_buffer_pool_size=32M innodb_log_file_size=48M innodb_autoextend_increment=64 innodb_buffer_pool_instances=8 innodb_concurrency_tickets=5000 innodb_old_blocks_time=1000 innodb_open_files=300 innodb_file_per_table=1 innodb_checksum_algorithm=0 back_log=80 flush_time=0 join_buffer_size=256K max_allowed_packet=4M max_connect_errors=100 open_files_limit=4161 sort_buffer_size=256K table_definition_cache=1400 binlog_row_event_max_size=8K sync_master_info=10000 sync_relay_log=10000 sync_relay_log_info=10000 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Custom config should go here !includedir /etc/mysql/conf.d/
下面这3行,占用只有285M左右,下降了大约177M
performance_schema_max_table_instances=600 table_definition_cache=400 table_open_cache=256