如何修改ubuntu服务器的MySQL root密码和用户名?我需要停止mysql服务之前,设置任何更改?
我有一个phpmyadmin设置以及,phpmyadmin会自动更新?
如何修改ubuntu服务器的MySQL root密码和用户名?我需要停止mysql服务之前,设置任何更改?
我有一个phpmyadmin设置以及,phpmyadmin会自动更新?
当前回答
关于这个话题的大多数答案都过时了;在写这个答案之前,MySQL发生了两个主要的变化:
1-用户表中的“Password”字段已被“authentication_string”列取代。
2-“Password”加密功能:Password(“of some text”)已弃用。
更多信息请参考此链接:dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
其他回答
Instead of resetting the password there is a work around on the local machine if you have setup phpmyadmin to connect without giving the password or username. Check this out by starting mysql, apache etc. I have xampp installed in my local machine. So starting the xampp will start all the necessary services. Now going to http://localhost/phpmyadmin shows me all the databases. This confirms that you have saved the username and passsword in the config file of phpmyadmin which can be found in the phpmyadmin install location. If you have xampp installed the phpmyadmin folder can be found in the root folder of xampp installation. Search for the word password in the config.inc.php file. There you will find the password and username.
修改MySQL root密码。
此方法将密码暴露到命令行历史记录中,这些命令应该以root身份运行。
通过mysql命令行工具登录: Mysql -uroot -poldpassword 执行如下命令: SET PASSWORD FOR root@ localhost = PASSWORD('newpassword');
or
运行此命令,为当前用户设置密码(在本例中为'root'): SET PASSWORD = PASSWORD('newpassword');
关于这个话题的大多数答案都过时了;在写这个答案之前,MySQL发生了两个主要的变化:
1-用户表中的“Password”字段已被“authentication_string”列取代。
2-“Password”加密功能:Password(“of some text”)已弃用。
更多信息请参考此链接:dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
你可以尝试以下步骤来重置mysql的root密码:
首先停止Mysql服务
sudo /etc/init.d/mysql stop
以root用户登录,不需要密码 Sudo mysqld_safe—skip-grant-tables &
登录mysql终端后,你需要执行更多的命令:
use mysql;
UPDATE mysql.user SET authentication_string=PASSWORD('solutionclub3@*^G'), plugin='mysql_native_password' WHERE User='root';
flush privileges;
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
重启mysql服务器后 如果你仍然面临错误,你必须访问: 重置MySQL的root密码
如果你知道你当前的密码,你不需要停止mysql服务器。 打开ubuntu终端。 登录mysql使用:
mysql - username -p
然后输入密码。 这将带您进入mysql控制台。 在控制台内部,输入:
> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
然后使用:
> flush privileges;
然后你就完成了。