centos7 mysql 5.7 yum installation

Start the installation of centos7 mysql

  1. Download the rpm package
    wget from the official https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
  2. Install the rpm package
    sudo rpm -ivh mysql57-community-release-el7-11.noarch.rpm
  3. 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
  1. Modify the file vim /etc/my.cnf file and add skip-grant-tables=1 [ password verification is not performed at startup ]
  2. Restart mysql, enter mysql -uroot -p
  3. After entering the database, switch the mysql library use mysql
  4. 执行命令↓
    update user set authentication_string = password('123456'), password_expired = 'N', password_last_changed = now() where user = 'root';
  5. Exit mysql and delete the skip-grant-tables=1 entry in the /etc/my.cnf file
  6. 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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324404686&siteId=291194637
Recommended