mysql reset password

https://www.centos.bz/2011/04/reset-mysql-root-password/


大概步骤如下:
1:停止mysql服务器
2:使用mysqld_safe启动mysql
3:修改root密码
4:退出,重启mysql服务器


步骤一:停止mysql服务器的几个方法如下:
1. 通过 service mysqld stop 来停止mysql
2. 如果不行,则直接使用kill命令停止myqld服务,首先需要使用 ps aux | grep mysql 来查看mysql相关的进程pid,(使用ps aux可以看到pid为第二列),然后使用 kill -9 XXXX 依次杀掉


步骤二:使用mysqld_safe启动mysql
使用如下命令启动mysql:


1mysqld_safe --skip-grant-tables &
直到看到以下提示,才表示启动成功 
Starting mysqld daemon with databases from /var/lib/mysql 
以root账号登陆mysql 

1mysql -u root

步骤三:修改mysql root密码


1
2
3
4
mysql> use mysql;
mysql> update user set password = PASSWORD ( "NEW-ROOT-PASSWORD" ) where User = 'root' ;
mysql> flush privileges ;
mysql> quit;



步骤四:重启mysql


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
As an AI language model, I don't have the ability to physically reset a MySQL master server, but I can provide the general steps that can be followed to reset a MySQL master server: 1. Stop the MySQL service on the master server using the command "systemctl stop mysql" (for systems using systemd) or "service mysql stop" (for systems using init.d). 2. Edit the MySQL configuration file (usually located at /etc/mysql/my.cnf) and add the following lines under the [mysqld] section: skip-slave-start log-bin = /var/log/mysql/mysql-bin.log server-id = 1 These lines will disable the replication (skip-slave-start), enable binary logging (log-bin), and set the server ID to 1. 3. Delete the binary log files and the relay log files from the data directory (usually located at /var/lib/mysql). You can do this by running the command "rm -rf /var/lib/mysql/*-bin.*". 4. Start the MySQL service using the command "systemctl start mysql" or "service mysql start". 5. Connect to the MySQL server using the command "mysql -u root -p" and run the following commands: RESET MASTER; FLUSH TABLES WITH READ LOCK; SHOW MASTER STATUS; These commands will reset the binary log, flush the tables, and show the current master status. 6. Take note of the file name and position from the output of the SHOW MASTER STATUS command. 7. Exit the MySQL shell by running the command "exit". 8. Update the slave servers with the new master information by running the following command on each slave server: CHANGE MASTER TO MASTER_HOST='master_hostname', MASTER_USER='replication_user', MASTER_PASSWORD='replication_password', MASTER_LOG_FILE='master_log_file_name', MASTER_LOG_POS=master_log_file_position; Replace the values inside the single quotes with the appropriate values for your setup. 9. Start the replication on each slave server using the command "START SLAVE;". That's it! Your MySQL master server should now be reset and ready for replication.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值