Cambiar la clave de root en un servidor MySQL o MariaDB
Cambiar la clave de root en un servidor MySQL o MariaDBIntroducción
En muchas ocasiones
es necesario cambiar la contraseña root de la base de datos Mysql o MariaDB,
eso es porque se le olvido, puede ser que en su primera instalación inicial no tenía
conciencia de guardar la contraseña. No importa la razón, te enseñare los pasos
para solucionar este asunto.
Desarrollo
Primero que nada, asegúrese
que el servicio mariadb esté ejecutándose:
Entonces ejecutamos
#
systemctl is-active mariadb
Si el resultado es
active entonces debe ejecutar el siguiente comando
systemctl
start mariadb
Si el resultado fue
failed olvide el paso anterior.
systemctl
is-active mariadb
[root@s198-12-148-97 /]# mysql -u root -p
[root@s198-12-148-97 /]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB
MariaDB Server
Copyright (c) 2000, 2018, Oracle,
MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type
'\c' to clear the current input statement.
MariaDB [(none)]>
Paso posterior se
debe ejecutar el siguiente comando:
USE mysql;
UPDATE user SET
password=PASSWORD('MiClaveAqui') WHERE User='root' AND Host = 'localhost';
El próximo paso
consistirá en salir de la sesión actual al escribir
exit
Puede comprobar con
la nueva contraseña.
en CENTOS 7 ESTA CONFIGURACIÓN SERIA LA MAS ADECUADA:
en CENTOS 7 ESTA CONFIGURACIÓN SERIA LA MAS ADECUADA:
To begin, stop the database service and check the service status, we should see the environment variable we set previously:
Next, start the service with
--skip-grant-tables
:
This will allow you to connect to the database server as root without a password (you may need to switch to a different terminal to do so):
From then on, follow the steps outlined below.
Finally, stop the service, unset the environment variable and start the service once again:
This will cause the previous changes to take effect, allowing you to connect to the database server using the new password.Resumen
Para realizar estos
pasos es necesario contar con el usuario root del sistema Linux. En este caso
se hizo la prueba con centos7.
Comentarios
Publicar un comentario