1.登陸mysql或者mariadb(兩種任選其一)
[root@localhost ~]# mysql -u root
[root@localhost ~]# mysql -uroot -p
2.切換到存儲用戶名和密碼的數據庫
MariaDB [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.修改密碼,適用password()函數進行加密,實際上就是執行sql語句來更新指定用戶的密碼
MariaDB [mysql]> update user set password=password('新密碼') where user='要更新密碼的用戶名';回車
-> ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 5 Changed: 0 Warnings: 0
4.刷新用戶權限列表
MariaDB [mysql]> flush privileges;回車
Query OK, 0 rows affected (0.00 sec)
5.退出mysql登陸
MariaDB [mysql]> quit
Bye
6.重啟mysql或者mariadb服務
[root@localhost ~]# service mysqld restart(重啟mysql)
[root@localhost ~]# service mariadb restart(重啟mariadb)