在ubuntu中重置mysql服务器root密码的方法_MySQL
程序员文章站
2022-05-17 12:29:52
...
Ubuntu
bitsCN.com
首先停止mysql服务:
root@webserver:/home/webmaster# service mysql stop
接着采用忽略密码认证模式重新创建一个mysql服务:
root@webserver:/home/webmaster# 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)
连接到mysql系统库:
root@webserver:/home/webmaster# mysql -u root mysql
连接到mysql库后直接修改root帐号的密码为新的密码'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见前面启动服务时的屏幕信息):
root@webserver:/home/webmaster# kill 3591
正常启动 mysql服务,并用新密码登录mysql服务器成功:
root@webserver:/home/webmaster#service mysql start
root@webserver:/home/webmaster#mysql -u root -pmynewpasswd
bitsCN.com
root@webserver:/home/webmaster# service mysql stop
接着采用忽略密码认证模式重新创建一个mysql服务:
root@webserver:/home/webmaster# 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)
连接到mysql系统库:
root@webserver:/home/webmaster# mysql -u root mysql
连接到mysql库后直接修改root帐号的密码为新的密码'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见前面启动服务时的屏幕信息):
root@webserver:/home/webmaster# kill 3591
正常启动 mysql服务,并用新密码登录mysql服务器成功:
root@webserver:/home/webmaster#service mysql start
root@webserver:/home/webmaster#mysql -u root -pmynewpasswd
bitsCN.com
上一篇: 再问一个PHP数组格式有关问题,
推荐阅读
-
MySQL重置root密码提示"Unknown column ‘password"的解决方法
-
lnmp重置mysql数据库root密码的两种方法
-
MySQL重置root密码提示"Unknown column ‘password"的解决方法
-
详解如何在Linux中重置MySQL或者MariaDB的root密码
-
在MySQL中修改密码及访问限制的设置方法详解
-
重置mysql的root密码最简单的方法
-
windows下重置mysql的root密码方法介绍
-
ubuntu系统中Mysql ERROR 1045 (28000): Access denied for user root@ localhost问题的解决方法
-
MySQL root密码的重置方法
-
CentOS中对MySql的root用户重置密码