mysql install

MySQL install on CentOS 7

從官網下載yum repo
https://dev.mysql.com/downloads/repo/yum/
mysql57-community-release-el7-11.noarch.rpm

安裝

yum -y install mysql-community-server.x86_64

重設root password
如果忘記root密碼 需要重設時 先打開skip-grant-tables選項
可在/etc/my.cnf [mysqld]下加上
skip-grant-tables

/etc/my.cnf
[mysqld]
skip-grant-tables
#...

然後重啟server

mysql -u root
即可登入進去,但注意 重設password會跳出error說還是在skip-grant-tables mode
此時先刷新privileges

flush privileges;

再來將password重設

shell> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');
mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('new_password');
mysql> SET PASSWORD FOR 'root'@'::1' = PASSWORD('new_password');
mysql> SET PASSWORD FOR 'root'@'%' = PASSWORD('new_password');
This entry was posted in System Administration. Bookmark the permalink.

Leave a Reply