App Overlays
The following sections list the instructions to verify/login into DB applications:
MongoDBβ
To set up and Log into MongoDB, follow these steps:
- Type
mongoshin the command line or terminal and press Enter to start the MongoDB shell. - To set password:
- Run
use admincommand. - Create a new user with administrative privileges by running the following command:
db.createUser({
Β user: "admin",
Β pwd: "your_password_here",
Β roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]}) - To open the MongoDB configuration file, enter
sudo nano /etc/mongod.conf. - Navigate to security section and add the following line:
security:authorization: "enabled" - Restart the MongoDB service to apply the changes:
sudo systemctl restart mongod - To open the MongoDB shell and to authenticate, type the following command:
mongosh -u admin -p your_password_here --authenticationDatabase admin
- Run
For more information about creating database and collection, refer MongoDB documentation.
MySQLβ
To set up and log into MySQL, follow these steps:
- To log into MySQL, type:
sudo mysql - To set a password for the Root User, use the following command:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password_here'; - Flush the privileges to ensure that the changes take effect:
FLUSH PRIVILEGES; - To exit the MySQL prompt, type
EXIT;. - To log in with the password, type
mysql -u root -p. - Enter the password when prompted.
For more information, refer MySQL documentation.
PostgreSQLβ
To set up and log into PostgreSQL, follow these steps:
- To log into PostgreSQL, switch to the postgres user and then access the PostgreSQL prompt:
sudo -i -u postgres - To access the PostgreSQL prompt, type
psql. - To set a password for the postgres user, run the following command:
ALTER USER postgres WITH PASSWORD 'your_password_here'; - To exit the PostgreSQL prompt, type
\q. - To ensure that PostgreSQL uses password authentication, edit the
pg_hba.conffile by typingsudo nano /etc/postgresql/14/main/pg_hba.confcommand. - Find the following lines:
localΒ Β allΒ postgresΒ peer
Change peer to md5:
localΒ Β allΒ postgresΒ md5 - Save and close the file.
- Restart the PostgreSQL service to apply the changes:
sudo systemctl restart postgresql - Log into PostgreSQL with the new password.
- To switch to the postgres user, type
sudo -i -u postgres. - Access the PostgreSQL prompt with the password:
psql -U postgres -W - Enter the password when prompted.
For more information, refer PostgreSQL documentation .
Redisβ
To set up and log into Redis, follow these steps:
- To log into Redis, type
redis-cliin the Redis Command-Line Interface (CLI). - To set the password, edit the
redis-configfile:sudo nano /etc/redis/redis.conf - Find the line that starts with
# requirepassand uncomment it by removing#. Then, set your password:requirepass your_password_here - Save and close the file.
- Restart the Redis server to apply the changes:
sudo systemctl restart redis-server - To login with a password, type:
redis-cli -a your_password_here.
For more information, refer Redis documentation.
Cassandraβ
To set up and log into Cassandra, follow these steps:
- To log into Cassandra using
cqlsh, open your terminal and typecqlsh. - To set the password, edit the
cassandra.yamlconfiguration file:sudo nano /etc/cassandra/cassandra.yaml - Find the following lines and set the authenticator to
PasswordAuthenticator:authenticator: PasswordAuthenticatorauthorizer: CassandraAuthorizer - Save and close the file.
- Restart the Cassandra service to apply the changes:
sudo systemctl restart cassandra - To login with a password, type:
cqlsh -u cassandra -p your_password_here.
For more information, refer Cassandra documentation.
Elasticsearchβ
To set up passwords for the built-in users, you can use the elasticsearch-setup-passwords tool. You can run this tool in either auto mode or interactive mode.
- Auto Mode - This mode automatically generates passwords for all built-in users:
sudo /usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto - Interactive Mode - This mode allows you to set passwords manually:
sudo /usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive
Follow the prompts to set passwords for the built-in users, including the elastic users. To verify password setup, make an authenticated request to Elasticsearch by using the following command:
curl -u elastic:your_password_here -X GET "localhost:9200/"
Using Kibana (Optional)β
Kibana is optional but highly recommended for managing and visualizing Elasticsearch data.
- To configure Kibana:
- Edit the
kibana.ymlconfiguration file to set the Elasticsearch URL and credentials:
sudo nano /etc/kibana/kibana.yml - Add the following commands:
elasticsearch.username: "elastic"elasticsearch.password: "your_password_here" - Start Kibana and type:
sudo systemctl start kibana && sudo systemctl enable kibana - To access the Kibana, navigate to http://localhost:5601 in your web browser and log in with the elastic user credentials.
- Edit the
For more information, refer the following links: Elasticsearch documentation, Elasticsearch Guide.