剛安裝完MySQL後默認用戶名和密碼都是root,安全起見,必須把密碼修改掉,那麼如何修改呢?
1.用默認賬號密碼登錄MySQL服務端
[root@domin ~]# mysql -u root -p
2.切換到mysql庫
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
3.執行更改密碼的語句
mysql> update user set password=password('aaa') where user='root';
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3 Changed: 3 Warnings: 0
4.刷新權限表
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
5.現在退出就可以用新密碼登錄啦~
mysql> exit;
Bye