当你忘记mysql密码时,没准你可以这样做

Sometimes you can clobber your configuration. As such, it’s easier to start over, as if the package had never been installed. In your case, we are looking at MySQL.

1. use Yum to Remove MySQL, like so:

$ yum remove mysql mysql-server

2. removed MySQL, and safely backup the configuration:

$ mv /var/lib/mysql /var/lib/mysql_old_backup

3. If you’d rather remove it

$ rm -vR /var/lib/mysql

4. Now we can safely reinstall MySQL, using the default configuration that is included in the package from the Official MySQL repository (we need wget to fetch the rpm that will update your repos):

$ yum install wget

5. Now download and install the repository:

$ wget
http://repo.mysql.com/mysql-c… && rpm -ivh mysql-community-release-el7-5.noarch.rpm

6. Verify the repositories are installed:

$ ls -1 /etc/yum.repos.d/mysql-community*

7. install command

$ yum install mysql-server

8. If you ever need to set the password after using the script, use:

mysql -u root

9.Start and Stop the daemon like so:

systemctl start mysqld

    原文作者:Cristic
    原文地址: https://segmentfault.com/a/1190000015976180
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞