Linux (CentOS) install MySQL 5.7

#MySQL Profile

(1) MySQL industry mainstream version

   - 5.6

   - 5.7

(2) Enterprise Edition Select

  - Oracle: MySQL official version

  - RedHat:  MariaDB

  - Percona: PerconaDB

(3) Select version

  - generally choose 5.6 or 5.7

  - GA

  --6--12 month product version

# Download MySQL

  - From the official website: https://dev.mysql.com/downloads/

  - Select this article: https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz

#MySQL installation

  - OS version

[root@CentOS-Docker ~]# uname -a
Linux CentOS-Docker 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

  - remove the existing database (if so, to avoid affecting each other)

yum remove mariadb-libs-5.5.60-1.el7_5.x86_64

   - the necessary installation package

yum install -y libaio-devel ncurses-devel

  - Create an installation directory

mkdir -p /app/

   - unpack rename &

mv mysql-5.7.20-linux-glibc2.12-x86_64 mysql

   - modify environment variables

vim / etc / Profile 
# added at the end 
Export the PATH = / App / MySQL / bin: $ the PATH 

# into force 
source / etc / profile

  - New user mysql

useradd mysql

   - create the relevant directory and modify permissions

 mkdir /data/mysql -p 
 chown -R mysql:mysql /app/*
 chown -R mysql:mysql /data/*

   - initialize the database

# Clear the data / data / mysql in, the data will complain 
RM -rf / data / mysql / * 
# temporary password initialization data and administrators 
mysqld --initialize --user = mysql --basedir = / app / mysql - = -datadir / the Data / MySQL 
# no [ERROR] that success 
# 5.7 new features important Note: 
# 5.7 from the beginning, MySQL added a new security password: 
# 1 after initialization is complete, it will generate a temporary password ( displayed on the screen, and will remember to log a) 
# 2 password complexity: chaos character combinations. 
# 3 password expiration time of 180 days. 
# initialization data, initialize the administrator's password is blank 
mysqld --initialize-insecure - -user = mysql --basedir = / app / mysql --datadir = / data / mysql

   - edit the configuration file

vim /etc/my.cnf
[mysqld]
user=mysql
basedir=/app/mysql
datadir=/data/mysql
server_id=6
port=3306
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock
prompt=3306 [\\d]>

   - Start MySQL

 cd /app/mysql/support-files
 ./mysql.server start

   - Use systemd management mysql

vim /etc/systemd/system/mysqld.service 
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/app/mysql/bin/mysqld --defaults-file=/etc/my.cnf
#systemctl start/stop/restart/status mysqld

   - manage passwords

mysqladmin -uroot -p password 123

   - Query

select user,authentication_string,host from mysql.user;

 

 

  

  

Guess you like

Origin www.cnblogs.com/crossworld/p/11518702.html