Start the installation of centos7 mysql
- Download the rpm package
wget from the official https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm - Install the rpm package
sudo rpm -ivh mysql57-community-release-el7-11.noarch.rpm - yum源安装
sudo yum remove mysql-community-server.x86_64 mysql-community-client.x86_64
- After the installation is successful, check the password↓ ( may not see it after entering the command, but it appears after I start mysql )
grep 'temporary password' /var/log/mysqld.log
change Password
- I have tried several ways to change the password and it seems unsuccessful, and finally choose the following rude way
- Modify the file vim /etc/my.cnf file and add skip-grant-tables=1 [ password verification is not performed at startup ]
- Restart mysql, enter mysql -uroot -p
- After entering the database, switch the mysql library use mysql
- 执行命令↓
update user set authentication_string = password('123456'), password_expired = 'N', password_last_changed = now() where user = 'root'; - Exit mysql and delete the skip-grant-tables=1 entry in the /etc/my.cnf file
- Restart mysql and enter mysql -uroot -p to enter with the new password
Set up remote login
- enter mysql
-
mysql -uroot -p # 选择 mysql 库 use mysql # 更新记录 update user set host = '%' where user = 'root';
exit mysql
-
#编辑配置文件 vim /etc/my.cnf #增加配置项 bind-address = 0.0.0.0
restart mysql
mysql start, stop, restart commands
# 启动
systemctl start mysqld.service
# 停止
systemctl stop mysqld.service
# 重启
systemctl restart mysqld.service