您现在的位置是:首页 > Elasticsearch8.0 > php-client > 正文
php-client
elasticsearch设置访问密码
vi bin/elasticsearch.yml设置xpack.security.enabled: true
vi bin/elasticsearch.yml 设置 xpack.security.enabled: true
设置内置用户的密码
Elasticsearch提供了一组内置用户,如elastic
、kibana
、logstash_system
等。你可以通过运行以下命令来设置这些内置用户的密码
./bin/elasticsearch-setup-passwords interactive
执行该命令后,系统会提示你为每个内置用户设置密码。你需要为每个用户输入并确认密码。
执行./bin/elasticsearch-setup-passwords interactive,出现以下报错
按照提示执行
./bin/elasticsearch-reset-password -u elastic
表示要重置elastic的密码
把上面的密码,输入然后就可以登陆了
php通过setBasicAuthentication配置登陆用户名和密码(xxx为上面重置生成的密码)就可以连接了
$client = Elastic\Elasticsearch\ClientBuilder::create()->setBasicAuthentication('elastic', 'xxxx')->setHosts(['http://129.211.188.74:9200'])->build();