CentOS Installation of mysql 5.7 and Simple Configuration Tutorial Explanation

  • 2021-07-06 11:59:33
  • OfStack

Installation

Ensure that your users have permission to install

root is not switched

su root

(su means swich user)

# rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm

You may encounter

warning: /var/tmp/rpm-tmp.6V5aFC: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Can be ignored (personal opinion, Baidu did not find a suitable answer after 1 time)


# yum install mysql-community-server 

Wait for installation to complete....

Configure

Find the initial password after installation here:


grep 'temporary password' ar/log/mysqld.log 

mysql 5.7 requires password complexity. If you want to create a simple password, you can first execute


set global validate_password_policy=0;

Re-create users

The newly installed server should pay attention to shutting down SELinux, otherwise it may encounter many problems caused by permissions


setenforce 0
vi/etc/selinux/config

Replace ENFORCE=enforcing with ENFORCE=disable

Configuration file

Linux: /etc/my.cnf
Windows: my. ini in the installation directory

Default character set

Versions prior to 5.6


[mysqld]
default-character-set=utf8 

Versions after 5.6


[mysqld]
character-set-server=utf8

Modify the character set of an existing database


alter database mydb default character set utf8;

Table names are not case sensitive


[mysqld]
lower_case_table_names=1

Allow function creation in log-bin mode


[mysqld]
log_bin_trust_function_creators=true

Turn on strict mode. If the field is too long in non-strict mode, it will be automatically truncated


[mysqld]
sql-mode="STRICT_TRANS_TABLES"

Related articles: