建立乙個/etc/yum.repos
.d/mongodb-org-3.6
.repo檔案
然後在裡面寫入:
[mongodb-org-3.6]
name=mongodb repository
baseurl=
.org/yum/redhat/$releasever/mongodb-org/testing/x86_64/
gpgcheck=0
enabled=1
gpgkey=
.org/static/pgp/server-3.6
.asc
yum -y install mongodb-org
記得關閉selinux
service mongod start 啟動
如果用本地連 ,進入 /etc/mongod.conf
把 127.0
.0.1 改為 0.0
.0.0 (如果注釋不管用的話)
#coding:utf8
import pymongo
# 建立連線
mongoclient = pymongo.mongoclient(host='192.168.6.6',port=27017)
# 指定運算元據庫
db = mongoclient['alice']
# 指定操作表(collection)
sheet = db['host']
try:
# 增加一條
# sheet.insert()
# db.host.insert()
# 修改
# sheet.update(,},multi=true)
# 刪除
# sheet.remove()
#查詢# res = sheet.find()
# for item in res:
# print item,type(item)
pass
except exception,e:
print str(e)
寫入
import pymongo
class
mongopipeline
(object):
def__init__
(self):
try:
#建立連線
self.mongoclient = pymongo.mongoclient(host='39.106.37.83',port=27017)
#制定運算元據庫
self.db = self.mongoclient['demo']
#指定操作表(collection)
self.sheet = self.db['host']
except exception,e:
print ('連線失敗')
print str(e)
defprocess_item
(self, item, spider):
try:
#增加一條
self.sheet.insert()
except exception,e:
print str(e)
pip install python-redis
2 tar zxvf 解壓
3 mv 移動到 /etc/local
4 cd redis裡 make 編譯
5 make install 安裝
6 cd src
7 ./redis-server 啟動服務
8 編輯redis-4.0.2下面的redis.conf
#69行注釋掉
69#bind 127.0.0.1
#88行yes改為no
88 protected-mode no
#136行 必須為no,否則連不上本地
136 daemonize no
9 複製到etc下
cp redis.conf /etc/redis.conf
7)新增全域性變數
export path=$path
:/usr/local/redis-
4.0.2/src
8)設定好全域性變數之後就可以啟動redis了
redis-server /etc/redis.conf
9)關閉redis
kill -9 redis埠
#檢視埠號
ps -aux | grep redis
本地連線mysql
1 上阿里雲 設定安全組 3306
2 進來linuxmysql
mysql -u root -p
use mysql
grant
allprivileges
on *.* to root@"***.***.***.***" identified by
"密碼";
flush privileges;
select
user,password,host from
user; #檢視是否新增成功
如果還是不行,在linux介面執行
iptables -l -n --line-numbers
iptables -d input 5
本地連線遠端資料庫
1.對所有使用者進行授權 grant all privileges on to myuser identified by mypassword with grant option flush privileges 如果你想允許使用者myuser從ip為192.168.1.6的主機連線到mysql伺服...
本地連線多個資料庫操作
create proc otherconnsql asbegin selectid u id,name u name,tel u tel from openrowset sqlncli server local trusted connection yes select u id,u name,u ...
關於資料庫連線的一些小知識點
由於在資料庫連線部分,新建連線的時候一直報 出錯原因 超時時間已到。超時時間已到,但是尚未從池中獲取連線。出現這種情況可能是因為所有池連線均在使用,並且達到了最大池大小。於是,我便想檢視一下資料庫的活動連線,看看究竟是哪個程式占用了過多的資料庫連線。我們可以用sp who 或sp who2 來顯示所...