Bước 1: stop mysql service:
Code:
[root@localhost ~]# /etc/init.d/mysqld stop
Stopping MySQL: [ OK ]
bước 2: Start to MySQL server w/o password:
Code:
[root@localhost ~]# mysqld_safe --skip-grant-tables &
[1] 3139
[root@localhost ~]# nohup: ignoring input and wwwecting stderr to stdout
Starting mysqld daemon with databases from /var/lib/mysql
Bước 3: Connect to mysql server using mysql client:
Code:
mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.51a Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
Bước 4: Setup new MySQL root user password
Code:
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
Code:
mysql> update user set password=PASSWORD("123456") where User='root';Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql>
Code:
mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)
mysql> exit;
Bye
[root@localhost ~]#
Bước 5:Stop MySQL Server:
Code:
[root@localhost ~]# /etc/init.d/[color=orange]mysqld[/color] stop
STOPPING server from pid file /var/run/mysqld/mysqld.pid
080901 17:15:22 mysqld ended
Stopping MySQL: [ OK ]
[1]+ Done mysqld_safe --skip-grant-tables
Bước 6: Start MySQL server and test it
Code:
[root@localhost ~]# /etc/init.d/[color=orange]mysqld[/color] start
Starting MySQL: [ OK ]
[root@localhost ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
ps: Bước 2 kết quả khác so với bài hướng dẫn. bước 5 + 6 : trong bài hướng dẫn là mysql nhưng tìm trong thư mục /etc/init.d/ không có. kết quả vân không khắc phục được