*. mysql
docker run --detach --name mysql \-e MYSQL_ROOT_PASSWORD=qwe123 \-p 3306:3306 \-v /container_mount/mysql:/var/lib/mysql \docker.io/mysqldocker run -it --rm docker.io/mysql \mysql -h 10.63.132.219 -P 3306 -u root -p*. mongo
启动:
docker run --detach --name mongo \-e MONGO_INITDB_ROOT_USERNAME=mytest \-e MONGO_INITDB_ROOT_PASSWORD=qwe123 \-p 27017:27017 \-v /container_mount/mongo:/data/db \docker.io/mongo连接:
docker run -it --rm docker.io/mongo \mongo 10.63.132.219:27017 \-u mytest -p qwe123 --authenticationDatabase admin c). 操作:
db.getName();
show dbs;
use sm_db
show collections
db.groups.find()*. postgre
启动
docker run --detach --name postgre \-p 5432:5432 \-e POSTGRES_PASSWORD=qwe123 \-e POSTGRES_USER=mytest \-v /container_mount/postgre:/var/lib/postgresql/data \docker.io/postgres连接
docker run -it --rm docker.io/postgres \psql -h 10.63.132.219 -p 5432 -U mytest -W操作:
用户
\du 批量查询数据库:
CREATE DATABASE sm_db OWNER mytest;
\l 批量查询
\c mytest; 切换数据库表操作
CREATE TABLE json_test(id varchar primary key,name varchar,json_value json
);
\d 批量查询
\d table_name 查看表结构
drop table table_name;数据操作:
insert into json_test values('001', 'app-1', '{"cpu": 1, "gpu": 1,"ports": [1000, 1001]}');
delete from json_test where id='001';
update json_test set json_value = '{}' where id = '001';
select * from json_test;参考:
https://mozillazg.com/2014/06/hello-postgresql.htmlrm -rf /container_mount/mongo
docker stop mysql && docker rm mysql
docker stop mongo && docker rm mongo
docker stop postgre && docker rm postgre
docker logs -f mongo