1. 程式人生 > >EMM mysql和MongoDB資料庫基本操作

EMM mysql和MongoDB資料庫基本操作

一、公司使用的MySQL資料庫基本操作1、進入MYSQL容器: docker-enter MYSQL連線資料庫:mysql -uemm_user -pemmpass2、檢視資料庫mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || analy_db || emm_db |+--------------------+3、進入公司EMM使用的主要資料庫emm_db;use emm_db;
4、檢視資料庫中的表show tables;5、查詢某張表中的資料,如組織機構資料:mysql> select * from t_Organization limit 1 \G; mysql> select * from t_Organization where id='555' \G; 條件查詢 6、更新表中某個資料的某個欄位值 UPDATE t_Organization SET orgId='10000001' where id='521';二、MYSQL 資料庫相關簡單備份還原操作:主要與SAP對接人員時使用到相關備份還原操作1、備份整個emm_db資料庫
mysqldump -uemm_user -p emm_db > emm_db.sql 備份整個人 emm_db 資料庫表2、備份emm_db;資料庫下面的某個資料表(Personnel ) mysqldump -uemm_user -p emm_db Personnel > /data/backup/Personnel.sql3、資料庫還原(匯入資料庫和資料表)3.1 匯入整個資料庫 mysql -uemm_user -p emm_db < /data/emm_db.sql3.2 匯入emm_db 資料庫中的 某個表(如:Personnel ) mysql -uemm_user -p emm_db < /data/Personnel .sql
三、公司使用的MongoDB資料庫的連線和資料查詢操作1、進入mongo 容器 docker-enter MONGO2、連線mongo3、檢視資料庫> show dbs;_db2ade2fb25beabc575d9b686d481f0ca6 0.078GB_db83bfa4ec9cbc9c1460ee3d5bb6b7a36e 0.203GBbaas 0.078GBlocal 0.078GBmas_counter 8.074GBtestZJYC 0.078GB4、切換資料庫---推送資料庫> use _db2ade2fb25beabc575d9b686d481f0ca6;switched to db _db2ade2fb25beabc575d9b686d481f0ca65、條件查詢--功能:查詢相關推送資料有沒有存到資料庫中 db.getCollection("_Notification").find({"pushTarger.users":"99999"}).sort({createdAt:-1}).limit(1);1 row in set (0.00 sec)檢視EMM組織機構資訊:emm_db 資料庫中 select id,name,orgId from t_Organization;重置根組織機構的組織機構ID UPDATE t_Organization SET orgId='10000001' where id='521';清空的命令是?delete from tableName 連上MySQL。use emm_db;