MySQL: Zapomenuté heslo roota

Nacházíte se: / Linux / How to ...

Vypneme mysql server:

/etc/init.d/mysql stop

Zapneme mysql server v safe modu (nenačítají se tabulky s právama):

server:~# /usr/bin/mysqld_safe --skip-grant-tables & mysql
server:~# Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[23484]: started

Spustíme konzolovýho mysql klienta (tady je už vidět, že nechce žádný přihlašovací údaje):

server:~# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.38-Debian_1-log Debian etch distribution

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

mysql>

U mojí verze MySQL serveru to ještě chtělo vybrat nějakou databázi:

mysql> USE mysql;
Database changed

A už jenom nastavím práva:

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.12 sec)

mysql> GRANT ALL PRIVILEGES ON * to root@localhost IDENTIFIED BY 'nove_heslo';
Query OK, 0 rows affected (0.05 sec)

A je to :) Teď už jen pro jistotu:

/etc/init.d/mysql restart