ssdb.conf中找到auth字段,更改如下:

  1. # ssdb-server config
  2. # MUST indent by TAB!
  3. # relative to path of this file, directory must exists
  4. work_dir = ./var
  5. pidfile = ./var/ssdb.pid
  6. server:
  7. ip: 127.0.0.1
  8. port: 8888
  9. # bind to public ip
  10. #ip: 0.0.0.0
  11. # format: allow|deny: all|ip_prefix
  12. # multiple allows or denys is supported
  13. #deny: all
  14. #allow: 127.0.0.1
  15. #allow: 192.168
  16. # auth password must be at least 32 characters
  17. #auth: very-strong-password #只要加上这个就好啦
  18. auth: rTVB9Fm2l2rctOJlIzVxIN0BreQQoiET
  19. #readonly: yes
  20. replication:
  21. binlog: yes
  22. # Limit sync speed to *MB/s, -1: no limit
  23. sync_speed: -1
  24. slaveof:
  25. # to identify a master even if it moved(ip, port changed)
  26. # if set to empty or not defined, ip:port will be used.
  27. #id: svc_2
  28. # sync|mirror, default is sync
  29. #type: sync
  30. #host: localhost
  31. #port: 8889
  32. logger:
  33. level: debug
  34. output: log.txt
  35. rotate:
  36. size: 1000000000
  37. leveldb:
  38. # in MB
  39. cache_size: 500
  40. # in MB
  41. write_buffer_size: 64
  42. # in MB/s
  43. compaction_speed: 1000
  44. # yes|no
  45. compression: yes

记得要重启下:

  1. ./ssdb-server ssdb.conf -s stop
  2. ./ssdb-server -d ssdb.conf

在使用的时候,用auth方法认证下就可以了。
php代码如下:

  1. <?php
  2. // require_once('SSDB.php');
  3. $ssdb = new SimpleSSDB('127.0.0.1', 8888);
  4. $ssdb->auth('KlvnbgnewerEvanOvTuWiQuobk22aiv5');
  5. $resp = $ssdb->set('key', '123');
  6. $resp = $ssdb->get('key');
  7. echo $resp; // output: 123

附:
启动和停止

  1. # 启动主库, 此命令会阻塞住命令行
  2. ./ssdb-server ssdb.conf
  3. # 或者启动为后台进程(不阻塞命令行)
  4. ./ssdb-server -d ssdb.conf
  5. # 停止 ssdb-server
  6. ./ssdb-server ssdb.conf -s stop
  7. # 对于旧版本
  8. kill `cat ./var/ssdb.pid`
  9. # 重启
  10. ./ssdb-server ssdb.conf -s restart

[1]ssdb官网

分类: web

标签:   ssdb