Ubuntu 忘记 phpMyAdmin 登录密码

Ubuntu 忘记 phpMyAdmin 登录密码

关于phpMyAdmin

phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web. phpMyAdmin supports a wide range of operations on MySQL and MariaDB. Frequently used operations (managing databases, tables, columns, relations, indexes, users, permissions, etc) can be performed via the user interface, while you still have the ability to directly execute any SQL statement.

0X00 找到my.cnf文件

登录ubuntu系统,找到文件:my.cnf,一般来说文件的位置为:/etc/mysql/my.cnf,如不存在,建议在系统直接查找locate my.cnf | grep cnf

root@ubuntu:/# locate my.cnf | grep cnf
/etc/mysql/my.cnf

0x01 跳过

使用vim /etc/mysql/my.cnf[mysqld]目录下加上一句skip-grant-tables,使用键盘ESC退出,然后输入wq保存!

[mysqld]
#
# * Basic Settings
#
skip-grant-tables 
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

0x02 重启

使用命令 service mysql restart重启mysql服务

root@ubuntu:/# service mysql  restart
mysql stop/waiting
mysql start/running, process 3978

0x03 设置账号密码

输入mysql进入,重新设置账号密码update mysql.user set password=password('jidd@u123.') where user='root';之后在刷新权限flush privileges

root@ubuntu:/# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.5.54-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2016, 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>

我这里设置密码为jidd@u123.

mysql> update mysql.user set password=password('jidd@u123.') where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

刷新权限

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

0x04 实现正常登录

终端实现正常登录

root@ubuntu:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.5.54-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2016, 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.

web页面的登录
为

0X05 完成密码修改

最后不要忘记重复使用vim /etc/mysql/my.cnf[mysqld]目录下注释掉:#skip-grant-tables,使用键盘ESC退出,输入wq保存!然后重启service mysql restart,希望能够帮到你解决问题。

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 游动-白 设计师:上身试试 返回首页