docker 安装mysql

】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

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值