標籤:
- 首先停止mysql服務
/etc/init.d/mysql stop
2. 接著採用忽略密碼認證模式重新建立一個mysql服務
mysqld --user=mysql --skip-grant-tables --skip-networking &
成功啟動後返回PID及其它啟動資訊
[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)
3. 串連到mysql系統庫
mysql -u root mysql
4. 串連到mysql庫後直接修改root帳號的密碼為新的密碼‘123456‘
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> update user set Password=PASSWORD(‘123456‘) where user=‘root‘; Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> FLUSH PRIVILEGES; mysql> quit; Bye
5. 中止mysql服務進程
kill 3591
6.正常啟動mysql服務,並用新密碼登入mysql伺服器
service mysql start
mysql修改root密碼