Guia de Redefinição da Senha do Banco de Dados
Na administração diária de bancos de dados, redefinir a senha do banco de dados é uma operação comum e necessária. Seja por motivos de segurança, esquecimento de senha ou outros motivos, entender como redefinir a senha do banco de dados é crucial para os administradores de banco de dados. Este artigo detalha como redefinir as senhas dos bancos de dados MariaDB, PostgreSQL e Redis. Ao usar o ServBay, deve-se atentar para as diferentes versões dos bancos de dados que possuem diferentes configurações e caminhos.
Redefinindo a Senha do MariaDB
MariaDB é um fork do MySQL e um popular sistema de gerenciamento de banco de dados relacional. Os passos a seguir orientam como redefinir a senha do MariaDB.
A seguir, será utilizado como exemplo a versão MariaDB 10.11
Processo de Redefinição de Senha do MariaDB
Pare o serviço do MariaDB:
bashservbayctl stop mariadb 10.11
1Inicie o MariaDB em modo seguro:
bash/Applications/ServBay/package/mariadb/10.11/current/bin/mysqld_safe --skip-grant-tables --skip-networking &
1Conecte-se ao MariaDB:
bash/Applications/ServBay/package/mariadb/10.11/current/bin/mysql -u root
1Redefina a senha:
sqlFLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password'; FLUSH PRIVILEGES;
1
2
3Saia do MariaDB:
sqlexit;
1Pare o serviço do MariaDB em modo seguro:
bashservbayctl stop mariadb 10.11
1Reinicie o serviço do MariaDB:
bashservbayctl start mariadb 10.11
1
Redefinindo a Senha do PostgreSQL
PostgreSQL é um poderoso sistema de banco de dados objeto-relacional de código aberto. Os passos a seguir orientam como redefinir a senha do PostgreSQL.
A seguir, será utilizado como exemplo a versão PostgreSQL 16
Processo de Redefinição de Senha do PostgreSQL
- Encontre a conta de administrador do PostgreSQL
Abra o painel de administração do ServBay em Configurações
-Senha do Banco de Dados
e encontre a Conta
do PostgreSQL.
Pare o serviço do PostgreSQL:
bashservbayctl stop postgresql 16
1Faça um backup do arquivo
pg_hba.conf
:bashcp /Applications/ServBay/db/postgresql/16/pg_hba.conf /Applications/ServBay/db/postgresql/16/pg_hba.conf.bak
1Edite o arquivo
pg_hba.conf
, removendo a autenticação por senha:bashsed -i '' 's/scram-sha-256/trust/g' /Applications/ServBay/db/postgresql/16/pg_hba.conf
1Inicie o PostgreSQL:
bashservbayctl start postgresql 16
1Acesse a linha de comando do
psql
:bashpsql -h /Applications/ServBay/tmp -U <usuário obtido na primeira etapa> postgres # Por exemplo: psql -h /Applications/ServBay/tmp -U servbay postgres
1
2Redefina a senha:
sqlALTER USER <usuário obtido na primeira etapa> WITH PASSWORD 'new_password'; -- Por exemplo: ALTER USER servbay WITH PASSWORD 'new_password';
1
2Saia do
psql
:sql\q
1Pare o serviço do PostgreSQL:
bashservbayctl stop postgresql 16
1Restaure o arquivo
pg_hba.conf
:bashcp /Applications/ServBay/db/postgresql/16/pg_hba.conf.bak /Applications/ServBay/db/postgresql/16/pg_hba.conf
1Reinicie o serviço do PostgreSQL:
bashservbayctl start postgresql 16
1
Redefinindo a Senha do Redis
Redis é um armazenamento de estrutura de dados em memória de código aberto, usado como banco de dados, cache e agente de mensagens. Os passos a seguir orientam como redefinir a senha do Redis.
Processo de Redefinição de Senha do Redis
Abra o arquivo de configuração do Redis:
bashvim /Applications/ServBay/package/etc/redis/redis.conf
1Encontre e modifique o item de configuração
requirepass
:plaintextrequirepass new_password
1Salve e saia do editor.
Reinicie o serviço do Redis:
bashservbayctl restart redis -all
1
Conclusão
Redefinir a senha do banco de dados é uma tarefa importante na administração de bancos de dados. Este artigo detalhou como redefinir as senhas dos bancos de dados MariaDB, PostgreSQL e Redis. Ao usar o ServBay, deve-se atentar para as diferentes versões dos bancos de dados que possuem diferentes configurações e caminhos. Seguindo esses passos, você pode garantir a segurança e acessibilidade do banco de dados. Seja por motivos de segurança ou esquecimento de senha, dominar essas habilidades ajudará você a gerenciar melhor o sistema de banco de dados.