如何修改ubuntu服务器的MySQL root密码和用户名?我需要停止mysql服务之前,设置任何更改?
我有一个phpmyadmin设置以及,phpmyadmin会自动更新?
如何修改ubuntu服务器的MySQL root密码和用户名?我需要停止mysql服务之前,设置任何更改?
我有一个phpmyadmin设置以及,phpmyadmin会自动更新?
当前回答
如果部署在xampp上,您可以通过提供的phpadmin gui轻松更改mysql密码。
phpMyAdmin -> User Accounts -> Edit Privileges (Select the intended user) -> Change Password (Tab)
其他回答
设置MySQL密码
停止MySQL数据库服务
sudo /etc/init.d/mysql stop
创建一个新的mysqld目录
Sudo mkdir /var/run/mysqld/
给予mysql用户访问权限
Sudo chown mysql /var/run/mysqld/
以安全模式启动MySQL…
Sudo mysqld_safe—skip-grant-tables &
无需密码登录数据库服务器
Sudo mysql -u root
使用默认的mysql数据库
使用mysql;
修改root密码
update user set authentication_string=PASSWORD(" new_passwor_here ") where user ='root';
保存更改 冲洗特权; 退出; 停止MySQL安全模式,启动MySQL默认服务
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
使用root新密码重新登录MySQL数据库
-u root -p
***来源:https://websiteforstudents.com/resetting-mysql-root-password-on-ubuntu-16-04-17-10-and-18-04-lts/
如果你想修改MySQL root密码,在终端输入:
Sudo dpkg-reconfigure mysql-server-5.5
MySQL守护进程将被停止,并提示您输入新密码。
我遇到ubuntu 18.04和mysql 5.7的问题,这是解决方案
执行命令前请尝试重新启动mysql-server
sudo service mysql restart
Mysql-server >= 5.7
sudo mysql -uroot -p
USE mysql;
UPDATE user SET authentication_string=PASSWORD('YOUR_PASSWORD') WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
quit;
Mysql-server < 5.7
sudo mysql -uroot -p
USE mysql;
UPDATE user SET password=PASSWORD('YOUR_PASSWORD') WHERE User='root';
UPDATE user SET plugin="mysql_native_password";
FLUSH PRIVILEGES;
quit;
你可以尝试以下步骤来重置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密码
唯一对我有效的方法是这里描述的(我运行的是ubuntu 14.04)。为了清晰起见,以下是我遵循的步骤:
sudo vim /etc/mysql/my.cnf Add the following lines at the end: [mysqld] skip-grant-tables sudo service mysql restart mysql -u root use mysql select * from mysql.user where user = 'root'; - Look at the top to determine whether the password column is called password or authentication_string UPDATE mysql.user set *password_field from above* = PASSWORD('your_new_password') where user = 'root' and host = 'localhost'; - Use the proper password column from above FLUSH PRIVILEGES; exit sudo vim /etc/mysql/my.cnf Remove the lines added in step 2 if you want to keep your security standards. sudo service mysql restart
参考:https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html