如何修改ubuntu服务器的MySQL root密码和用户名?我需要停止mysql服务之前,设置任何更改?
我有一个phpmyadmin设置以及,phpmyadmin会自动更新?
如何修改ubuntu服务器的MySQL root密码和用户名?我需要停止mysql服务之前,设置任何更改?
我有一个phpmyadmin设置以及,phpmyadmin会自动更新?
当前回答
您可以使用该命令:
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
之后请冲洗:
FLUSH PRIVILEGES;
其他回答
要更新“root”Mysql用户密码,你必须记住,你将需要超级用户权限。如果您拥有超级用户权限,请尝试执行以下命令:
MySQL 5.7.6及以上版本
sudo su
service mysql stop
mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
\q;
exit
mysql -u root -p MyNewPass
MySQL 5.7.5及更早版本
sudo su
service mysql stop
mysql -u root
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
\q;
exit
mysql -u root -p MyNewPass
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.
您可以使用该命令:
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
之后请冲洗:
FLUSH PRIVILEGES;
如果你想修改MySQL root密码,在终端输入:
Sudo dpkg-reconfigure mysql-server-5.5
MySQL守护进程将被停止,并提示您输入新密码。
你可以尝试以下步骤来重置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密码