jeudi 29 septembre 2011

MySQL : Mot de Passe Root Perdu...

Etape 1: Arreter le serveur MySQL. # /etc/init.d/mysql stop ou # service mysql stop
Etape 2: Redemarrer le service MySQL avec l'option --skip-grant-tables afin que celui ci ne te demande aucun mot de passe. # /usr/bin/mysqld_safe --skip-grant-tables &
Etape 3 : Se connecter au service mysql # mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Etape 4 : Changer le mot de passe Root mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit;

Etape 5: Arreter le serveur MySQL. # /etc/init.d/mysql stop ou # service mysql stop
Etape 6 : Redémarrer le serveur en mode normal # /etc/init.d/mysql start ou # service mysql start

mercredi 21 septembre 2011

Script du jour

Il peut être utile de savoir (re)démarrer un service quand celui ci est arreté...
petite demo avec le service apache2
vi service_down_to_up.sh copie colle ... #!/bin/bash
# Service Process Monitor
# Restart a Service When It Goes Down
# ----------------------------------------------------------
# Copyright (c) 2011 David H.
# ----------------------------------------------------------

SERVICE_NAME="apache2"
RESTART="service $SERVICE_NAME restart"

# path to pgrep command
PGREP=$(which pgrep)

# find service pid
$PGREP ${SERVICE_NAME}

[ $? -ne 0 ] && $RESTART || : # if service not running

sudo chmod +x service_down_to_up.sh
./service_down_to_up.sh