mysql修改密碼的三方法和忘記root密碼的解決方法
更新時間:2014年02月17日 11:17:08 作者:
這篇文章主要介紹了mysql修改密碼的三方法和忘記root密碼的解決方法,需要的朋友可以參考下
方法1: 用SET PASSWORD命令
復(fù)制代碼 代碼如下:
mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
方法2:用mysqladmin
復(fù)制代碼 代碼如下:
mysqladmin -u root password "newpass"
如果root已經(jīng)設(shè)置過密碼,采用如下方法
復(fù)制代碼 代碼如下:
mysqladmin -u root password oldpass "newpass"
方法3: 用UPDATE直接編輯user表
復(fù)制代碼 代碼如下:
mysql -u root
mysql> use mysql;
mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';
mysql> FLUSH PRIVILEGES;
在丟失root密碼的時候,可以這樣
復(fù)制代碼 代碼如下:
mysqld_safe --skip-grant-tables&
mysql -u root mysql
mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';
mysql> FLUSH PRIVILEGES;
相關(guān)文章
php mysql insert into 結(jié)合詳解及實例代碼
在mysql中如果要保存數(shù)據(jù)到數(shù)據(jù)庫我們就會用到insert into命令了,下面我來給大家介紹mysql insert into幾種常用的使用方法,需要的朋友可以參考下2016-11-11
MySQL常用命令 MySQL處理數(shù)據(jù)庫和表的命令
這篇文章主要介紹了MySQL常用命令,尤其是針對MySQL處理數(shù)據(jù)庫和表的命令進(jìn)行學(xué)習(xí),特別適用于新手,感興趣的小伙伴們可以參考一下2015-11-11

