ubuntu下安裝了mysql 5 server忘記(jì)root密碼怎(zěn)麽辦?
在(zài)ubuntu下安(ān)裝了mysql 5 server,結果不(bú)知道(dào)什麽原(yuán)因(yīn),安裝時輸入的(de)root帳號密碼在使(shǐ)用(yòng)時(shí)無論如(rú)何都不能通過數(shù)據(jù)庫服務器的驗證。無奈隻(zhī)有重置mysql的root帳號密(mì)碼。查了(le)一下,用了以下方法成功的重置了root帳號密(mì)碼
ubuntu下(xià)安裝(zhuāng)了mysql5 server 忘記了root密碼怎麽(me)辦?怎樣重(chóng)置(zhì)root密碼(mǎ)呢?
停止mysql服務:
代碼如下:
root@webserver:/home/webmaster# service mysql stop
接著采用忽(hū)略密(mì)碼認證模(mó)式(shì)重新(xīn)創建一個mysql服務:
代碼如下(xià):
root@webserver:/home/webmaster# mysqld --user=mysql --skip-grant-tables --skip-networking &
成(chéng)功啟動後返(fǎn)回PID及其它啟(qǐ)動信(xìn)息(xī)
代碼如下:
[1] 3591 root@webserver:/home/webmaster# 121005 2:59:27 [Note] Plugin 'FEDERATED' is disabled. 121005 2:59:27 InnoDB: The InnoDB memory heap is disabled 121005 2:59:27 InnoDB: Mutexes and rw_locks use GCC atomic builtins 121005 2:59:27 InnoDB: Compressed tables use zlib 1.2.3.4 121005 2:59:27 InnoDB: Initializing buffer pool, size = 128.0M 121005 2:59:27 InnoDB: Completed initialization of buffer pool 121005 2:59:27 InnoDB: highest supported file format is Barracuda. 121005 2:59:27 InnoDB: Waiting for the background threads to start 121005 2:59:28 InnoDB: 1.1.8 started; log sequence number 1595685 121005 2:59:28 [Note] mysqld: ready for connections. Version: '5.5.24-0ubuntu0.12.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 0 (Ubuntu)
連接(jiē)到mysql係統庫:
代碼如(rú)下:
root@webserver:/home/webmaster# mysql -u root mysql
連接到mysql庫後直接修改root帳號的密碼為新的(de)密碼'mynewpasswd':
代碼如下:
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> update user set Password=PASSWORD('mynewpasswd') where user='root'; Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> FLUSH PRIVILEGES; mysql> quit; Bye
中止mysql服務進程(PID 3591見前(qián)麵(miàn)啟動(dòng)服務時的屏幕信息(xī)):
代碼如下:
root@webserver:/home/webmaster# kill 3591
正常啟動 mysql服務,並用(yòng)新密碼登錄mysql服務器成功:
代碼如(rú)下:
root@webserver:/home/webmaster#service mysql start root@webserver:/home/webmaster#mysql -u root -pmynewpasswd
關鍵詞:ubuntu,mysql
閱讀本文後您有(yǒu)什麽感想? 已(yǐ)有 人給出評價(jià)!
- 1
- 30
- 1
- 23
- 32
- 72