Home  >  Article  >  Database  >  Detailed introduction to the sample code for installing mysql5.7.17 using RPM under Linux

Detailed introduction to the sample code for installing mysql5.7.17 using RPM under Linux

黄舟
黄舟Original
2017-03-16 13:53:291405browse

This article mainly introduces in detail the relevant code of using RPM to install mysql5.7.17 under linux, which has certain reference value. Interested friends can refer to the

MySQL5.7 rpm installation method record under Linux for your reference. The specific content is as follows

Delete the old package:

# rpm -qa | grep -i mysql
# rpm -ev mysql-libs-* --nodeps

Install rpm package:

# rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm
# rpm -ivh mysql-community-libs-5.7.17-1.el7.x86_64.rpm
# rpm -ivh mysql-community-client-5.7.17-1.el7.x86_64.rpm
# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm

Start, stop:

# service mysqld start
# service mysqld stop
# service mysqld status

Initial random password :

# cat /var/log/mysqld.log | more

Modify the initial password and authorize remote access:

# mysql -uroot -p
mysql> set password='Pwd@123456';
mysql> grant all privileges on *.* to 'root'@'%' identified by 'Pwd@123456';

Password complexityAttributes:

mysql> set global validate_password_policy=0;

validate_password_policy has the following values: (The default is 1, which is MEDIUM, so the password you set at the beginning must meet the length, and must contain numbers, lowercase or uppercase letters, special characters.)

Modify the data directory:

The new directory needs to be authorized for the mysql user, mysqld_safe log file authorization, and selinux is closed (no relevant policy setting method was found)


# mkdir /data/mysql/data
# mv /var/lib/mysql/* /data/mysql/data/
# mkdir /data/mysql/log
# chown mysql:mysql -R /data/mysql
# touch mysqld_safe.log
# chown mysql:mysql mysqld_safe.log
# vi /etc/my.cnf
/**
[client]
port = 3306
socket = /data/mysql/log/mysql.sock
default-character-set=utf8

[mysql]
no-auto-rehash
socket=/data/mysql/log/mysql.sock
default-character-set=utf8

[mysqld]
port = 3306
socket = /data/mysql/log/mysql.sock
character-set-server=utf8
lower_case_table_names=1
basedir=/usr
datadir=/data/mysql/data
log-error=/data/mysql/log/error.log
pid-file=/data/mysql/log/mysql.pid
init_connect='SET NAMES utf8'
symbolic-links=0

skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M

[mysqld_safe]
log-error=/data/mysql/log/mysqld_safe.log
*/
# getenforce
Enforcing
# setenforce 0
# vi /etc/selinux/config
/**
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#   enforcing - SELinux security policy is enforced.
#   permissive - SELinux prints warnings instead of enforcing.
#   disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#   targeted - Targeted processes are protected,
#   mls - Multi Level Security protection.
SELINUXTYPE=targeted 
*/
# service mysqld start

Other commands:


# mysqladmin -u root -p password
mysql> select version();


# chkconfig --list
# chkconfig --level 345 mysqld on
# netstat -na | grep 3306

The above is the detailed content of Detailed introduction to the sample code for installing mysql5.7.17 using RPM under Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn