Mysql5.7.21 installation documentation
1. Create a user group mysql, create a user mysql, add it to the user group mysql, and grant read and write permissions
Groupadd mysql-create a mysql user group group
Useradd-r-g mysql mysql-create a mysql user and add it to the mysql user group
Chown-R mysql mysql/-- assign mysql directory access to the myql user
Chgrp-R mysql mysql/-the user group that changes the mysql directory belongs to the mysql group
2. Create an installation directory
Mkdir-p / oracle/app/mysql/data
Chown-R mysql.mysql / oracle/app/mysql
-- 3. Upload and decompress MySQL files
Cd / oracle/app/mysql
Mv / software/V974639-01.zip.
Unzip V974639-01.zip
Tar zxf mysql-advanced-5.7.21-el7-x86_64.tar.gz
4. Create a configuration file, save and exit
Vim / etc/my.cnf
[client]
Port = 3307
Socket = / oracle/app/mysql/data/mysql.sock
[mysqld]
Character_set_server=utf8
Init_connect='SET NAMES utf8'
Basedir=/oracle/app/mysql
Datadir=/oracle/app/mysql/data
Socket=/oracle/app/mysql/data/mysql.sock
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
Lower_case_table_names = 1
Sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Max_connections=5000
Default-time_zone ='+ 8VR 00'
5. Initialize the database
-- create log files
Cd / var/log/
Vim mysqld.log
: wq
Chmod 777 mysqld.log
Chown mysql:mysql mysqld.log
-initialize the database
/ oracle/app/mysql/bin/mysqld-initialize-user=mysql-basedir=/oracle/app/mysql-datadir=/oracle/app/mysql/data-lc_messages_dir=/oracle/app/mysql/share-lc_messages=en_US
Note: libaio needs to be installed
Yum install libaio
-- 6. View initialization password
Cat / var/log/mysqld.log
Last line: root@localhost: here is the initial password
Root@localhost: A8#OH=pkfSf5
Start the MySQL service, change the initial password, and run the remote connection test
/ oracle/app/mysql/support-files/mysql.server start
Set password=password ('mysql5.7')
Flush privileges
UPDATE `mysql`.`user`SET `Host` ='%', `User` = 'root' WHERE (`Host` =' localhost') AND (`User` = 'root')
# then do the following to start the mysql service and set the relevant permissions
Cd / oracle/app/mysql/data
Vim mysqld.pid
Chmod 777 mysqld.pid
Chown mysql:mysql mysqld.pid
/ oracle/app/mysql/support-files/mysql.server start
/ oracle/app/mysql/bin/mysql-uroot-p the initial password you saw above
# the following is the sql statement after entering the database
Use mysql
UPDATE `mysql`.`user`SET `Host` ='%', `User` = 'root', `Process_ priv` =' YQing, `Insert_ priv` = 'YQing, `Index_ priv` =' YQing, `Delete_ priv` = 'YQing, `Create_ priv` =' YQing, `Drop_ priv` = 'YQing, `Reload_ priv` =' YQing, `Process_ priv` = 'YQing, `File_ priv` =' YQing, `Grant_ priv` = 'YQing, `References_ priv` =' YQing, `Index_ priv` = 'YQing, `Alter_ priv` =' YQing, `Show_db_ priv` = 'YQing, Super_ priv` `Create_routine_ priv` = 'Show_view_ priv`, `Create_routine_ priv` =' Create_routine_ priv`, `Alter_routine_ priv` = 'YQing, `Create_user_ priv` =' YQing, `Create_user_ priv` = 'YQing, `Create_tablespace_ priv` =' YQing, `ssl_ type `='', `ssl_ cipher` ='', `x509issuer` ='' `x509FEFCAD70E433ED117376D292D2B299E433ED117376D292D2B299, `password_ changred` = 'password_ changed`, `password_last_ changed` =' 2018-4-12 12 max_ 41max_ 07, `password_ lifetime` = NULL, `account_ locked` ='N` WHERE (`User` = 'root')
Flush privileges
-- 8. Boot self-starting
Cd / oracle/app/mysql/support-files
Cp mysql.server / etc/init.d/mysqld
Chkconfig-add mysqld
9. Use systemctl start/stop mysqld.service to stop or start the service
Su-mysql
Systemctl stop mysqld.service
Systemctl start mysqld.service
Note: you need to enter the password of the root account in Linux
-- establish a remote user
Grant all privileges on *. * to 'padmin'@'%' identified by' padmin'
Flush privileges
-- add system path
Vim / etc/profile
Export PATH=/oracle/app/mysql/bin:$PATH
Source / etc/profile
This article refers to the relevant articles on the network.