Thứ Hai, 15 tháng 1, 2018

monogodb reset admin password


Comment:
vim /etc/mongod.conf
#security:
#security:
#  authorization: enabled

/etc/init.d/mongod restart

# mongo
> use admin
switched to db admin
> db.changeUserPassword("root", "wbqAz6zYT0")
> exit

Uncomment:

vim /etc/mongod.conf
#security:
security:
  authorization: enabled
/etc/init.d/mongod restart
Read More

Create User Mongodb

1. Connect to MongoDB
mongo --port 27017 -u siteUserAdmin -p password --authenticationDatabase admin
2. Create the new user.
use reporting
db.createUser(
    {
      user: "reportsUser",
      pwd: "12345678",
      roles: [
         { role: "read", db: "reporting" },
         { role: "read", db: "products" },
         { role: "read", db: "sales" },
         { role: "readWrite", db: "accounts" }
      ]
    }
)

Read More

Thứ Năm, 11 tháng 1, 2018

Backup to Google Drive



git clone https://github.com/bachvtuan/Backup-To-Google-Drive.git
pip install --upgrade google-api-python-client 
pip install --upgrade oauth2client==1.5.2
pip install PyOpenSSL

  1. you create your google drive api first at Link.
  2. After google drive project is created, You go to API & Auth tab and click on Credentials. From here, click on button with label Create new Client ID and select service account and click on Create Client ID button , after created service account, you download the private key to somewhere such as I put at path "configs/74214843aee8aba9f11b7825e0a22ef1f06533b7-privatekey.p12" and copy service account id such as "xxxxx-5kfab22qfu82uub2887gi0c9e6eincmu@developer.gserviceaccount.com"
  3. You come back to your google drive drive.google.com and create share folder( you create an empty folder and right click on the folder and share to user xxxxx-5kfab22qfu82uub2887gi0c9e6eincmu@developer.gserviceaccount.com ) and copy the folder id ( You can look at the url after visit folder and the id is there ) and in my case the backup folder url is https://drive.google.com/#folders/0B0XTTQmH9aXreFdxS0txVU5Xb1U so that the id is 0B0XTTQmH9aXreFdxS0txVU5Xb1U
  4. Create config file( such as config_file.json ) and input into this file with json format such as
    {
     "service_account":"xxxxx-5kfab22qfu82uub2887gi0c9e6eincmu@developer.gserviceaccount.com",
     "private_key12_path":"configs/74214843aee8aba9f11b7825e0a22ef1f06533b7-privatekey.p12",
     "backup_folder_id":"0B0XTTQmH9aXreFdxS0txVU5Xb1U",
     "description" : "Description for backup file",
     "max_file_in_folder": 5
    }

Read More

pip install fails with “connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)”

Error SSL when install using pip

#  pip install --upgrade google-api-python-client
Collecting google-api-python-client
  Could not fetch URL https://pypi.python.org/simple/google-api-python-client/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579) - skipping
  Could not find a version that satisfies the requirement google-api-python-client (from versions: )
No matching distribution found for google-api-python-client

Solution:

# pip install --upgrade google-api-python-client --trusted-host pypi.python.org
Read More