linuxmysql忘記root密碼了
一.MySQL密碼的恢復方法之一
如果忘記了MySQL的root密碼,可以用以下方法重新設置:
1.切換到root下
su root
2. KILL掉系統里的MySQL進程;
killall -TERM mysqld
3. 用以下命令啟動MySQL,以不檢查許可權的方式啟動;
safe_mysqld --skip-grant-tables &
4. 然後用空密碼方式使困卜用root用戶登錄 MySQL;
mysql -u root
5. 修改root用戶的密碼;
mysql> update mysql.user set password=PASSWORD('123456') where User='root';
mysql>攔銀 flush privileges;
mysql> quit
重新啟動MySQL,就可以使用新密碼登錄了。
二. MySQL密碼的恢復方法二
有可能你的系統沒有 safe_mysqld 程序(ubuntu操作系統, apt-get安裝的mysql) , 下面汪衡穗方法可以恢復
1.切換到root下
su root
2. 停止mysqld;
/etc/init.d/mysql stop
3. 用以下命令啟動MySQL,以不檢查許可權的方式啟動;
mysqld --skip-grant-tables &
4. 然後用空密碼方式使用root用戶登錄 MySQL;
mysql -u root
4. 修改root用戶的密碼為123456(當然,你需要將123456改成你要設置的密碼);
mysql> update mysql.user set password=PASSWORD('123456') where User='root';
mysql> flush privileges;
mysql> quit
重新啟動MySQL
/etc/init.d/mysql restart
就可以使用新密碼 123456 登錄了。
❷ Linux下MySQL忘記root密碼怎麼辦
1.首先確認伺服器出於安全的狀態,也就是沒有人能夠任意地連接MySQL資料庫。
因為在重新設置MySQL的root密碼的期間,MySQL資料庫完全純禪出於沒有密碼保護的
狀態下,其他的用戶也可以任意地登錄和修改MySQL的信息。可以採用將MySQL對
外的埠封閉,並且停止Apache以及所有的用戶進程的方法實現伺服器的准安全
狀態。最安全的狀態是到伺服器的Console上面操作,並且拔掉網線。
2.修改MySQL的登錄設置:
# vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
例寬褲悔如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
保存並且退出vi。
3.重新啟動mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
4.登錄並修改MySQL的root密碼
# /usr/bin/慎正mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.56
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
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
mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
5.將MySQL的登錄設置修改回來
# vi /etc/my.cnf
將剛才在[mysqld]的段中加上的skip-grant-tables刪除
保存並且退出vi。
6.重新啟動mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
❸ linux mysql的root的密碼忘了怎麼辦
Linux下如果忘記MySQL的root密碼,可以通過修改配置的方法,重置root密碼
工具/原料
MySQL
Linux
方法/步驟
修改MySQL的配置文件(默認為/etc/my.cnf),在[mysqld]下添加一行skip-grant-tables
保存配置文件後,重啟MySQL服務 service mysqld restart
3
再次進入MySQL命令行 mysql -uroot -p,輸入密碼時直接回車,就會進入MySQL資料庫了,這個時候按照常規流程修改root密碼即可。
4
密碼修改完畢後,再按照步驟1中的流程,刪掉配置文件中的那行,並且重啟MySQL服務,新密碼就生效了。
❹ Linux下MySQL忘記root密碼怎麼辦
改MySQL的登錄設置:
# vi /etc/my.cnf
在[mysqld]的段中加上櫻銷一句:skip-grant-tables
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
保存並且退出vi。
3.重新啟動mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
4.登錄並修改MySQL的root密碼
# /usr/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.56
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
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
mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
5.將MySQL的登錄設置修改回來檔頌陪
# vi /etc/my.cnf
將剛才在[mysqld]的段中加上的行蠢skip-grant-tables刪除
保存並且退出vi。
6.重新啟動mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
❺ Linux下MySQL忘記root密碼怎麼辦
如果mysql密碼忘記了,可以用skip-grant-tables參數無密碼訪問後修改。
1、vi
my.cnf
在[mysqld]下增加一行
skip-grant-tables
2、重啟mysql
/etc/init.d/mysqld
restart
3、無密碼登陸
mysql
-uroot
-p
4、修改root密碼
use
mysql
select
user,password,host
from
user;
UPDATE
user
SET
Password
=
password
(
『newpasswd』
)
WHERE
user
=
『root』
and
host=』localhost』;
5、將my.cnf里的skip-grant-tables刪除
❻ Linux下MySQL忘記root密碼怎麼辦
解首辯決方法如下:
讓mysql不載入兆廳許可權表,命令:mysqld --skip-grant-tables(windows)、者猜缺mysqld_safe --skip-grant-tables user=mysql或者
/etc/init.d/mysql start --mysqld --skip-grant-tables (linux)
打開另外一個命令窗口,進入mysql的交互界面,密碼隨便輸入。
用update語句設置密碼(此時不能用set password語句)。
驗證密碼修改是否成功
❼ mysql資料庫root的密碼忘記了怎麼辦可以改嗎
mysql資料庫密碼忘記了,第一可以通過修改文件配置來重新設置密碼,第二可以重新下載mysql就可以重新設置密碼了。在我們使用資料庫的時候通常都會使用root用戶登錄,所以就需要設置密碼,但是這個密碼是不可見的,而且在使用Navicat Premium連接資料庫的時候也需要使用密碼才可以連接。當我們忘記密碼時,我們有兩種辦法來解決。
❽ linux mysql的root的密碼忘了怎麼辦
在丟失root密碼的時候,可以執行如下命令設置新的root密碼
1 跳過許可權檢查啟動mysql
$mysqld_safe--skip-grant-tables&
2 登陸mysql
$mysql-urootmysql
3 修改密碼
mysql>UPDATEuserSETpassword=PASSWORD("newpassword")WHEREser='root';
4 使許可權立即生效
mysql>FLUSHPRIVILEGES;
5 推出並正常啟動MySQL
❾ Linux下MySQL忘記root密碼怎麼辦
1.首先確認伺服器出於安全的狀態,也就是沒有人能夠任意地連接MySQL資料庫。
因為在重新設置MySQL的root密碼的期間,MySQL資料庫完全出於沒有密碼保護的
狀態下,其他的用戶也可以任意地登錄和修改MySQL的信息。可以採用將MySQL對
外的埠封閉,並且停止Apache以及所有的用戶進程的方法實現伺服器的准安全
狀態。最安全的狀態是到伺服器的Console上面操作,並且拔掉網線。
2.修改MySQL的登錄設置:
# vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables
保存並且退出vi。
3.重新啟動mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
4.登錄並修改MySQL的root密碼
# /usr/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.23.56
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
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
mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
5.將MySQL的登錄設置修改回來
# vi /etc/my.cnf
將剛才在[mysqld]的段中加上的skip-grant-tables刪除
保存並且退出vi。
6.重新啟動mysqld
# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
Work for fun,Live for love!
❿ Linux下MySQL忘記root密碼怎麼辦
Windows下的實際操作如下
1.關滲碰閉正在運行的MySQL。
2.打開DOS窗口,轉到mysql\bin目錄。
3.輸入mysqld --skip-grant-tables回車。如果沒有岩神出現提示信息,那就對了。
4.再開一個DOS窗口(因為剛才那個DOS窗口已經不能動了),轉到mysql\bin目錄。
5.輸入mysql回車,如果成功,將出現MySQL提示符 >
6. 連接許可權資料庫>叢棗談use mysql; (>是本來就有的提示符,別忘了最後的分號)
6.改密碼:> update user set password=password("520") where user="root"; (別忘了最後的分號)
7.刷新許可權(必須的步驟)>flush privileges;
8.退出 > \q
9.注銷系統,再進入,開MySQL,使用用戶名root和剛才設置的新密碼123456登陸。