】docker install mysql
$ docker search mysql (搜索mysql镜像)
$ docker pull mysql (下载mysql镜像,默认最新版本)
docker pull mysql:5.6 # 指定对应版本
docker启动mysql服务
docker run --name mysql -h mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
相关的参数可以自行查看文档:related parameters can be viewed by termselves
#进入容器
[root@localhost docker]# docker exec -it mysql /bin/bash
root@10ab732e1c60:/#
启动时的-h可以不加,会有默认镜像id root@10ab732e1c60:/# 10ab732e1c60就是默认的
root@10ab732e1c60:/# mysql -uroot -p123456
mysql> \s #查看相关参数
--------------
mysql Ver 14.14 Distrib 5.6.41, for Linux (x86_64) using EditLine wrapper
Connection id: 1
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.6.41 MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 2 min 6 sec
Threads: 1 Questions: 6 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg:
0.047--------------
账号远程授权:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'ip' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
刷新立即生效:
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
数据库引擎及字符编码可以通过navacat操作
navacat安装略过
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'ip' IDENTIFIED BY '123456';
FLUSH PRIVILEGES