30 Sep

Resetando a senha de Root do Mysql

Como sempre esqueço com fazer isso, vou deixar aqui, pra quando eu precisar novamente:

Como resetar a senha de Root do Mysql
===================================

[root@servidor ~]# lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
mysqld 31792 mysql 3u IPv4 434089 TCP *:mysql (LISTEN)
[root@servidor ~]# kill -9 31792
[root@servidor ~]# /etc/init.d/mysql start
Mysql Started

[root@servidor ~]# mysql
Access denied for user ‘root’@'localhost’ (using password: NO)

[root@servidor ~]# /etc/init.d/mysql stop

[root@servidor ~]# mysqld_safe –skip-grant-tables &

[root@servidor ~]#
[root@servidor ~]# mysql -u root
mysql>
mysql> use mysql;
mysql> update user set password=PASSWORD(“NEW-ROOT-PASSWORD”) where
User=’root’;
mysql> flush privileges;
mysql> quit

NEW-ROOT-PASSWORD above is whatever password you want to set.

[root@servidor ~]# # /etc/init.d/mysql stop
[root@servidor ~]# lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
mysqld 31792 mysql 3u IPv4 434089 TCP *:mysql (LISTEN)
[root@servidor ~]# kill -9 31792
[root@servidor ~]# fuser -k /usr/bin/mysqld_safe ( in
case you see mysql process is still running )

[root@servidor ~]# vi /root/.my.cnf
[root@servidor ~]# cat /root/.my.cnf
[client]
user=”root”
pass=”NEW-ROOT-PASSWORD”
[root@servidor ~]#

[root@servidor ~]# service mysql restart

[root@servidor ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.21-standard-log

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

mysql> quit
Bye
[root@servidor ~]#

One thought on “Resetando a senha de Root do Mysql

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>