本文目錄一覽:
- 1、linux mysql修改密碼命令
- 2、linux設置msyql密碼報錯怎麼辦
- 3、linux中的mysql數據庫密碼忘記了怎麼辦
- 4、LINUX下 設置mysql密碼遇到的問題 ERROR1064
- 5、linux mysql忘記密碼怎麼辦
- 6、linux下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 server at ‘localhost’ failed
error: ‘Access denied for user ‘root’@’localhost’ (using password: YES)’
linux mysql修改密碼命令方法2:直接更新user表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 ~]# service 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 reserved.
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 use mysql;
Database changed
mysql update user set password=password(‘new_password’) where user=’root’;
Query OK, 5 rows affected (0.00 sec)
Rows matched: 5 Changed: 5 Warnings: 0
mysql flush privileges;
Query OK, 0 rows affected (0.00 sec)
–注意:如果沒做step1,直接用mysql登錄時會報如下錯誤
[root@gc ~]# mysql
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)
Step 4: 將MySQL的登錄設置修改回來
再刪除/etc/my.cnf文件中的skip-grant-tables
Step 5: 重新啟動mysql
[root@gc ~]# service mysql restart
Shutting down MySQL..[確定]
Starting MySQL…[確定]
2.修改mysql其它用戶密碼
同樣,普通用戶也可以用上面的方法
–使用mysqladmin命令
[root@njdyw ~]# mysqladmin -u user1 -ppass1 password pass2
–直接修改數據庫表
[root@njdyw ~]# mysql -u user1 -ppass1 –Dmysql
mysql update user set password=password(‘pass2′) where user=’user1’;
mysql flush privileges;
linux設置msyql密碼報錯怎麼辦
原始密碼錯誤吧 根本就沒有連上數據庫啊 下面是忘記密碼的重置方法 有UnixLinux的也有Window的UnixLinux:
1.用root或運行mysqld的用戶登錄系統;
2.利用kill命令結束掉mysqld的進程;
3.使用–skip-grant-tables參數啟動MySQL Server
shellmysqld_safe –skip-grant-tables
4.為root@localhost
設置新密碼
shellmysqladmin -u root flush-privileges password “newpassword”5.重啟MySQL Server
GRANT ALL PRIVILEGES ON *.* TO
root@%
IDENTIFIED BY ’123’
linux下的解決方法:
關閉mysql
然後,safe_mysqld –skip-grant-tables
啟動mysql。
mysql -u root
mysql use mysql
mysql UPDATE user SET Password=PASSWORD(’xxx’) WHERE user=’root’;
mysql FLUSH PRIVILEGES;Window系統1.用系統管理員登陸系統。
2.停止MySQL的服務。
3.進入命令窗口,然後進入MySQL的安裝目錄中的bin目錄,比如我的安裝目錄是c:\mysql,進入C:\mysql\bin
4.跳過權限檢查啟動MySQL:c:mysqlbinmysqld-nt –skip-grant-tables
5.重新打開一個窗口,進入c:mysqlbin目錄,設置root的新密碼
c:mysqlbinmysqladmin -u root flush-privileges password “newpassword” //newpassword替換為你要用的root的密碼
c:mysqlbinmysqladmin -u root -p shutdown
//此時提示你輸入新密碼,重複第一個命令輸入的密碼。
6.MySQL Server已經停止,用正常模式啟動Mysql
7.ok了,你能用新的密碼鏈接到Mysql了。
linux中的mysql數據庫密碼忘記了怎麼辦
今天我們主要是講一下關於linux忘記mysql密碼處理方法,下面提供了5種linux忘記mysql密碼找回方法哦。
方法一:
# /etc/init.d/mysql stop
# mysqld_safe –user=mysql –skip-grant-tables –skip-networking
# mysql -u root mysql
mysql update user set password=password(newpassword) where user=root;
mysql flush privileges;
mysql quit
# /etc/init.d/mysql restart
# mysql -uroot -p
enter password: 輸入新設的密碼newpassword
mysql
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]節提供的用戶名和密碼:
# mysql -udebian-sys-maint -p
enter password: 輸入[client]節的密碼
mysql update user set password=password(newpassword) where user=root;
mysql flush privileges;
mysql quit
# mysql -uroot -p
enter password: 輸入新設的密碼newpassword
mysql
方法三:
這種方法我沒有進行過測試,因為我的root用戶默認密碼已經被我修改過了,那位有空測試一下,把結果告訴我,謝謝!!
# mysql -uroot -p
enter password: 輸入/etc/mysql/debian.cnf文件中[client]節提供的密碼
方法四:
方法如下: 1, 關閉mysql服務 /etc/init.d/mysqld stop 2,使用 –skip-grant-tables選項啟動mysql服務,可以修 改/etc/inin.d/mysqld腳本啟動位置增加此選項, vi /etc/init.d/mysqld
方法如下:
1, 關閉mysql服務
/etc/init.d/mysqld stop
2,使用 –skip-grant-tables選項啟動mysql服務,可以修 改/etc/inin.d/mysqld腳本啟動位置增加此選項,
vi /etc/init.d/mysqld
在下面運行啟動的語句里增加–skip-grant-tables
/usr/bin/mysqld_safe –skip-grant-tables –datadir=”$datadir” –socket=”$socketfile”
–log-error=”$errlogfile” –pid-file=”$mypidfile”
加入–skip-grant-tables的意思是啟動mysql服務的時候跳 過權限表認證。啟動後,連接到mysql的root不需要口令
3,重新啟動mysql服務
/etc/init.d/mysqld start
4. 修改root用戶的密碼;
mysql update mysql.user set password=password(123456) where user=root;
mysql flush privileges;
mysql quit
5. 重新啟動mysql,就可以使用 新密碼登錄了。
mysql
mysql -u root –p
輸入密碼:123456
6,關閉mysql服務
/etc/init.d/mysqld stop
7, 重新修改第2步修改的/etc/init.d/mysqld,使其保持原來不變,也就是取消–skip-grant-tables語句
8,重新 啟動mysql服務
/etc/init.d/mysqld start
LINUX下 設置mysql密碼遇到的問題 ERROR1064
mysqladmin這個命令是在shell命令行下執行的命令,而不是mysql里的命令,當然就報錯了。
使用chkconfig mysqld on就可以開機啟動了
linux mysql忘記密碼怎麼辦
可以多試一下常用密碼,大多數人設置密碼一般都是設置的常用密碼。或者注意一下密碼大小寫,全半角關係。有的也可以使用電話或者是郵箱地址找回密碼的功能。我用磁盤加鎖專家軟件也是忘記密碼後聯繫客服解決的,收到密碼提示後,發現也是自己常用的密碼,可能是自己輸入的時候不小心按到旁邊鍵導緻密碼錯誤。所以還可以先把密碼輸入到記事本上,然後再複製粘貼進去。希望能幫到你
linux下mysql密碼忘記了怎麼辦
今天我們主要是講一下關於linux忘記mysql密碼處理方法,下面提供了5種linux忘記mysql密碼找回方法哦。
方法一:
# /etc/init.d/mysql stop
# mysqld_safe –user=mysql –skip-grant-tables –skip-networking
# mysql -u root mysql
mysql update user set password=password(newpassword) where user=root;
mysql flush privileges;
mysql quit
# /etc/init.d/mysql restart
# mysql -uroot -p
enter password:
mysql
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]節提供的用戶名和密碼:
# mysql -udebian-sys-maint -p
enter password:
mysql update user set password=password(newpassword) where user=root;
mysql flush privileges;
mysql quit
# mysql -uroot -p
enter password:
mysql
方法三:
這種方法我沒有進行過測試,因為我的root用戶默認密碼已經被我修改過了,那位有空測試一下,把結果告訴我,謝謝!!
# mysql -uroot -p
enter password: etc/mysql/debian.cnf文件中[client]節提供的密碼
方法四:
方法如下: 1, 關閉mysql服務 /etc/init.d/mysqld stop 2,使用 –skip-grant-tables選項啟動mysql服務,可以修 改/etc/inin.d/mysqld腳本啟動位置增加此選項, vi /etc/init.d/mysqld
方法如下:
1, 關閉mysql服務
/etc/init.d/mysqld stop
2,使用 –skip-grant-tables選項啟動mysql服務,可以修 改/etc/inin.d/mysqld腳本啟動位置增加此選項,
vi /etc/init.d/mysqld
在下面運行啟動的語句里增加–skip-grant-tables
/usr/bin/mysqld_safe –skip-grant-tables –datadir=”$datadir” –socket=”$socketfile”
–log-error=”$errlogfile” –pid-file=”$mypidfile”
加入–skip-grant-tables的意思是啟動mysql服務的時候跳 過權限表認證。啟動後,連接到mysql的root不需要口令
3,重新啟動mysql服務
/etc/init.d/mysqld start
4. 修改root用戶的密碼;
mysql update mysql.user set password=password(123456) where user=root;
mysql flush privileges;
mysql quit
5. 重新啟動mysql,就可以使用 新密碼登錄了。
mysql
mysql -u root –p
輸入密碼:123456
6,關閉mysql服務
/etc/init.d/mysqld stop
7, 重新修改第2步修改的/etc/init.d/mysqld,使其保持原來不變,也就是取消–skip-grant-tables語句
8,重新 啟動mysql服務
/etc/init.d/mysqld start
原創文章,作者:簡單一點,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/128200.html