我不知道我的MySQL根密码;我怎么才能知道呢?是否有存储此密码的文件?

我正在跟踪这个链接,但我在本地没有directadmin目录。


当前回答

你可以查看mysql根密码,好吧,我已经在mysql 5.5上尝试过了,所以不知道其他新版本是否工作良好

nano ~/.my.cnf

其他回答

你可以查看mysql根密码,好吧,我已经在mysql 5.5上尝试过了,所以不知道其他新版本是否工作良好

nano ~/.my.cnf

mysql服务器安装后的默认密码是:mysql

您无法查看散列后的密码;你唯一能做的就是重置!

停止MySQL:

sudo service mysql stop

or

$ sudo /usr/local/mysql/support-files/mysql.server stop

以安全模式启动:

$ sudo mysqld_safe --skip-grant-tables

(上面一行是整个命令)

这将是一个持续的命令,直到进程结束,所以打开另一个shell/终端窗口,登录时不需要密码:

$ mysql -u root

mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';

MySQL 5.7及以上版本:

mysql> use mysql; 
mysql> update user set authentication_string=password('password') where user='root'; 

退出MySQL命令行:

mysql> exit 

在正常模式下重启MySQL,首先停止安全模式实例:

$ mysqladmin -u root -p shutdown   # (when prompted, enter the new password just set)
$ sudo service mysql start

or

$ sudo /usr/local/mysql/support-files/mysql.server start

你的新密码是“password”。

去phpMyAdmin > config.inc.php > $cfg['Servers'][$i]['password'] = ";

多亏了@thusharaK,我可以在不知道旧密码的情况下重置根密码。

在ubuntu上,我做了以下操作:

sudo service mysql stop
sudo mysqld_safe --skip-grant-tables --skip-syslog --skip-networking

然后在新的终端运行mysql:

mysql -u root

并执行如下命令修改密码:

UPDATE mysql.user SET authentication_string=PASSWORD('password') WHERE User='root';
FLUSH PRIVILEGES;

在MySQL 5.7中,MySQL中的password字段。用户表字段被删除,现在字段名是'authentication_string'。

退出mysql安全模式,启动mysql服务:

mysqladmin shutdown
sudo service mysql start