centOs7 install mysql records

Install

  1. Install dependencies
# 下载
shell> wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
# 安装 mysql 源
shell> yum localinstall mysql57-community-release-el7-11.noarch.rpm
  1. Use the following command to check whether the mysql source is installed successfully
shell> yum repolist enabled | grep "mysql.*-community.*"
  1. Start mysql
yum install -y mysql-community-server

Configuration

  1. Start mysql. The shutdown command is ( systemctl start|stop)
systemctl start mysqld
  1. View mysql status
systemctl status mysqld
  1. Set up auto-start at boot
systemctl enable mysqld
# 重载所有修改过的配置文件
systemctl daemon-reload
  1. Generate password
grep 'password' /var/log/mysqld.log
  1. set password

    1. Login mysql
      mysql -uroot -p
      
    2. set password
      ALTER USER 'root'@'localhost' IDENTIFIED BY 'ABCdef123!'; 
      
  2. Add an account that allows remote connections

GRANT ALL PRIVILEGES ON *.* TO 'GanYuHui'@'%' IDENTIFIED BY 'ABCdef123!' WITH GRANT OPTION;
  1. Allow root remote connections
use mysql;
UPDATE user SET Host='%' WHERE User='root';
flush privileges;
  1. Set the default encoding to utf8
vim /etc/my.cnf
 # 新增配置
[mysqld]
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
  1. Restart the mysql service
systemctl restart mysqld

Guess you like

Origin blog.csdn.net/weixin_43704471/article/details/108710634