Mysql如何修改用戶密碼
在使用mysql時,如果想修改用戶密碼,怎么修改?我們可以借助客戶端工具來修改,下面來看一下。
01打開客戶端工具Navicat,打開數據庫里的mysql庫,這是一個系統數據庫。
02打開后,在Tables表里,找到ur表,這是保存系統用戶的一個表數據。
03打開后,就可以在這里看到每個數據庫的用戶名和密碼了。
04要修改密碼,我們點擊單元格,讓其變成編輯狀態后,直接輸入新的密碼就行了。
mysql數據庫密碼修改
方法1: 用SET PASSWORD命令
首先登錄MySQL。 格式:mysql> t password for 用戶名@localhost = password(‘新密碼’); 例子:mysql> t password for root@localhost = password(‘123’);
方法2:用mysqladmin
格式:mysqladmin -u用戶名 -p舊密碼 password 新密碼 例子:mysqladmin -uroot -p123456 password 123
方法3:用UPDATE直接編輯ur表
首先登錄MySQL。 mysql> u mysql; mysql> update ur t password=password(‘123’) where ur=’root’ and host=’localhost’; mysql> flush privileges;
方法4:在忘記root密碼的時候,可以這樣 以windows為例:
1. 關閉正在運行的MySQL服務。 2. 打開DOS窗口,轉到mysqlin目錄。 3. 輸入mysqld –skip-grant-tables 回車。–skip-grant-tables 的意思是啟動MySQL服務的時候跳過權限表認證。 4. 再開一個DOS窗口(因為剛才那個DOS窗口已經不能動了),轉到mysqlin目錄。 5. 輸入mysql回車,如果成功,將出現MySQL提示符 >。 6. 連接權限數據庫: u mysql; 。 6. 改密碼:update ur t password=password(“123”) where ur=”root”;(別忘了最后加分號) 。 7. 刷新權限(必須步驟):flush privileges; 。 8. 退出 quit。 9. 注銷系統,再進入,使用用戶名root和剛才設置的新密碼123登錄。
mysql 忘記密碼 怎么修改密碼
怎么修改mysql的用戶名和密碼
linux mysql修改密碼命令
想知道linux下怎么修改密碼嗎?下面由我為大家整理了linux mysql修改密碼命令,希望大家喜歡!
linux mysql修改密碼命令
1.修改root密碼
linux mysql修改密碼命令方法1:使用mysqladmin命令
--適用于記得root舊密碼,修改root密碼
語法:
mysqladmin -u用戶名 -p舊密碼 password 新密碼
例如:
# mysqladmin -u root -proot password mysql
--注意:如當舊密碼輸入錯誤時會報如下錯誤
# mysqladmin -u root -proot1 password mysql
mysqladmin: connect to rver at 'localhost' failed
error: 'Access denied for ur 'root'@'localhost' (using password: YES)'
linux mysql修改密碼命令方法2:直接更新ur表password字段
--適用于忘記root密碼,而對root密碼進行重置
Step 1: 修改MySQL的登錄設置
# vi /etc/my.cnf
--windows系統是my.ini文件
--在[mysqld]的段中加上一句:skip-grant-tables,如沒有[mysqld]字段,可手動添加上
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-name-resolve
skip-grant-tables
Step 2: 重新啟動mysql
[root@gc ~]# rvice mysql restart
Shutting down MySQL..[確定]
Starting MySQL...[確定]
Step 3: 登錄并修改MySQL的root密碼
--此時直接用mysql即可無需密碼即可進入數據庫了
[root@gc ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.5.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights rerved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> u mysql;
Databa changed
mysql> update ur t password=password('new_password') where ur='root';
Query OK, 5 rows affected (0.00 c)
Rows matched: 5 Changed: 5 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 c)
--注意:如果沒做step1,直接用mysql登錄時會報如下錯誤
[root@gc ~]# mysql
ERROR 1045 (28000): Access denied for ur 'root'@'localhost' (using password: NO)
Step 4: 將MySQL的登錄設置修改回來
再刪除/etc/my.cnf文件中的skip-grant-tables
Step 5: 重新啟動mysql
[root@gc ~]# rvice mysql restart
Shutting down MySQL..[確定]
Starting MySQL...[確定]
2.修改mysql其它用戶密碼
同樣,普通用戶也可以用上面的方法
--使用mysqladmin命令
[root@njdyw ~]# mysqladmin -u ur1 -ppass1 password pass2
--直接修改數據庫表
[root@njdyw ~]# mysql -u ur1 -ppass1 –Dmysql
mysql> update ur t password=password('pass2') where ur='ur1';
mysql> flush privileges;
怎么修改mysql 用戶的密碼
本文發布于:2023-02-28 19:38:00,感謝您對本站的認可!
本文鏈接:http://www.newhan.cn/zhishi/a/167762526864707.html
版權聲明:本站內容均來自互聯網,僅供演示用,請勿用于商業和其他非法用途。如果侵犯了您的權益請與我們聯系,我們將在24小時內刪除。
本文word下載地址:mysql更改密碼(mysql修改密碼報錯).doc
本文 PDF 下載地址:mysql更改密碼(mysql修改密碼報錯).pdf
| 留言與評論(共有 0 條評論) |