[[email protected] ~]# docker pull mysql:5.7[[email protected]-no ~]# mkdir /iflytek/mysql/mysql.conf.d -pv
[[email protected]-no ~]# mkdir /iflytek/mysql/conf.d -p
[[email protected]-no ~]# mkdir /iflytek/mysql/data
[[email protected]-no mysql]# cat /iflytek/mysql/mysql.conf.d/mysqld.cnf
# Copyright (c)2014, 2016, Oracle and/or its affiliates. All rights reserved.
#
# This program isfree software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version2.0,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designatedin a particular file or component or inincluded license
# documentation. The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
#
# This program is distributedinthe hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License, version2.0, for moredetails.
#
# You should have received a copy of the GNU General Public License
# along with this program;if not, writeto the Free Software
# Foundation, Inc.,51 Franklin St, Fifth Floor, Boston, MA 02110-1301USA
#
# The MySQL Server configurationfile.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket= /var/run/mysqld/mysqld.sock
datadir= /var/lib/mysql
#log-error = /var/log/mysql/error.log
# By default we only accept connections from localhost
#bind-address = 127.0.0.1# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0[[email protected]-no mysql]# cat /iflytek/mysql/conf.d/mysql.cnf
[mysql]
default-character-set=utf8
[[email protected]-no ~]# docker run -it -d -p 3306:3306 -v /iflytek/mysql/mysql.conf.d/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf -v /iflytek/mysql/conf.d/mysql.cnf:/etc/mysql/conf.d/mysql.cnf -v /iflytek/mysql/data/:/var/lib/mysql -e MYSQL_ROOT_PASSWORD="[email protected]" mysql:5.79c7b2bc71c84137b10430d9f0e41f80ec63997e65390e1a64160dffcef853c64
[[email protected]-no mysql]# yum install mysql-client
[[email protected]-no mysql]# mysql -uroot [email protected]2020 -h172.31.242.80mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connectionid is 2Server version:5.7.31MySQL Community Server (GPL)
Copyright (c)2000, 2020, Oracle and/or its affiliates. All rights reserved.
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 clearthe current input statement.
mysql>show databases;+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00sec)
mysql> show global variables where variable_name like ‘character%‘;+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00sec)
mysql> create database jumpserver default charset ‘utf8‘ collate ‘utf8_bin‘;
Query OK,1 row affected (0.00sec)
mysql> grant all on jumpserver.* to ‘jumpserver‘@‘%‘ identified by ‘[email protected]‘;
Query OK,0 rows affected, 1 warning (0.00 sec)