Can I set username and password on memcached like mysql?

10,338

Solution 1

Yes, via SASL: http://code.google.com/p/memcached/wiki/SASLAuthProtocol

Solution 2

sasl_pwdb for more simple auth deployments

--enable-sasl-pwdb allows memcached to use it's own password file and verify a plaintext password. The file is specified with the environment variable MEMCACHED_SASL_PWDB, and is a plain text file with the following syntax:

username:password

Please note that you have to specify mech_list: plain in your sasl config file for this to work. Ex:

 echo "mech_list: plain" > memcached.conf
 echo "myname:mypass" > /tmp/memcached-sasl-db
 export MEMCACHED_SASL_PWDB=/tmp/memcached-sasl-db
 export SASL_CONF_PATH=`pwd`/memcached.conf
./memcached -S -v

and you should be able to use your favorite memcached client with sasl support to connect to the server. (Please note that not all SASL implementations support SASL_CB_GETCONF, so you may have to install the sasl config (memcached.conf) to the systemwide location)

Share:
10,338
Moein Hosseini
Author by

Moein Hosseini

I'm Moein who is into GNU/Linux, programming, open source and reading. Currently, I'm at AmirKabir University of Technology (Tehran Polytechnic) for M.S of Information Technology. My search interests are Natural Language Processing, Big Data and Machine Learning. Also, my thesis is about Forecasting the news impact on different aspects of social media users political opinions. Right now I work at BisPhone as Software Engineer. I took up my B.A in Computer Engineering from K.N.Toosi University of Technology and also graduated from Nodets for middle and high school.

Updated on June 04, 2022

Comments

  • Moein Hosseini
    Moein Hosseini almost 2 years

    I installed memcached and php-memcached on my ubuntu, I can connect to it by localhost on 11211 port. I can store data in it,but I wanna set username and password on it like when I connect to database. is it possible?how?

  • Olivier 'Ölbaum' Scherler
    Olivier 'Ölbaum' Scherler almost 10 years
    And where is that systemwide location?
  • Mosset Jérémie
    Mosset Jérémie about 4 years
    Content is down on this link.