MySQL 5 6 資料庫伺服器重置使用者密碼總結

2021-08-08 12:49:17 字數 991 閱讀 9102

mysql資料庫伺服器中重置密碼有兩種方法,一種是通過客戶端mysql,另一種是通過客戶端mysqladmin。

但無論使用哪種客戶端,都表明使用者登入遇到困難。所以首先要重啟mysql伺服器,禁用mysql伺服器的許可權系統如下:

mysqld --skip-grant-tables

然後在不鑑權的情況下,使用客戶端工具連線mysql伺服器。

方法一,通過客戶端mysql

1. 連線mysql伺服器

mysql -h localhost -u root
2. 重置root使用者的密碼

set password for 'root'@'localhost' = password('new_password');

或update mysql.user set password=password('newpassword') where user='root';

3.使修改生效

flush privileges;

4.客戶端退出連線

exit;

方法二,通過客戶端mysqladmin

mysqladmin -u root -h localhost password "new_password"

補充:重置匿名使用者登入密碼

1.客戶端連線到mysql伺服器

mysql -h localhost -u root -p

2.重置匿名使用者的密碼

set password for ''@'localhost' = password('new_password');

或update mysql.user set password=password('newpassword') where user='';

3.使修改生效

flush privileges;

4.客戶端退出連線

exit;

MySQL 伺服器重置密碼

在my.ini檔案的 mysqld 欄下新增skip grant tables 如果檔案中有,可能注釋掉了,這裡需要去掉注釋符號 改完後如下 mysql 設定mysql客戶端預設字符集 default character set utf8 mysqld skip grant tables 設定330...

mysql56資料庫的建立 mysql資料庫建立表

1.建立乙個名稱為employee的mysql預設型別myisam表 create table employee id smallint 5 not null,depno int 5 not null,name varchar 20 not null,cardnumber int 15 not nu...

mysql5 6更改資料庫編碼

今天在測試環境上出現了亂碼,但是同樣的程式在正式環境 阿里雲 沒有亂碼。檢視了一下mysql編碼發現,測試環境的編碼不全是utf8。所以需要將mysql的編碼都設定成utf8。正式環境和測試環境的mysql編碼截圖如下 解決方案如下 1 將mysql的安裝目錄的my default.ini複製乙份,...