centos7 .*tar package to install MySQL5.7

One, CentOS7.4 system comes with mariadb

# View the Mariadb that comes with the system
[ root@vmtest ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.44-2.el7.centos.x86_64
 
# Uninstall Mariadb that comes with the system
[ root@vmtest ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
 
# Delete my in the etc directory.cnf
[ root@vmtest ~]# rm /etc/my.cnf
  1. Check whether mysql exists
# Check if mysql exists
[ root@VMTest ~]# rpm -qa | grep mysql
[ root@VMTest ~]#

Three, check whether users and groups exist

1 ) Check if the mysql combined user exists

# Check if the mysql group and user exist, if not, create
[ root@VMTest ~]# cat /etc/group | grep mysql
[ root@VMTest ~]# cat /etc/passwd | grep mysql
# Query all users (just record, no need to execute)
[ root@VMTest ~]# cat /etc/passwd|grep -v nologin|grep -v halt|grep -v shutdown|awk -F ":"'{print $1 "|" $3 "1" $4}'| more
root|010
sync|510
mysql|99711001

2 ) If it does not exist, create the mysql group and user

# Create mysql user group
[ root@VMTest ~]# groupadd mysql
 
# Create a user named mysql and join the mysql user group
[ root@VMTest ~]# useradd -g mysql mysql
 
# Set the password to 111111[root@VMTest ~]# passwd mysql
Changing password for user mysql.
New password:
BAD PASSWORD: The password is a palindrome
Retype newpassword:
passwd: all authentication tokens updated successfully.

Fourth, download the tar package of mysql

https://dev.mysql.com/downloads/mysql/5.7.html#downloads

  1. Upload the mysql TAR package downloaded in step 4 to
# enter/usr/local/src folder
[ root@VMTest ~]# cd /usr/local/src/
 
# Upload mysql TAR package
[ root@VMTest src]# rz
 
# Unzip the tar file
[ root@VMTest src]# tar xvf mysql-5.7.22-el7-x86_64.tar
 
# Unzip mysql-5.7.22-el7-x86_64.tar.gz
[ root@VMTest src]# tar -zxvf mysql-5.7.22-el7-x86_64.tar.gz
 
# Move the decompressed file to/usr/local folder
[ root@VMTest src]# mv mysql-5.7.22-el7-x86_64 /usr/local
 
# enter/usr/Under local, modify to mysql
[ root@VMTest src]# cd /usr/local
[ root@VMTest local]# mv mysql-5.7.22-el7-x86_64 mysql

Six, change the group and user belonging to

# Change the group and user you belong to
[ root@VMTest local]# chown -R mysql mysql/[root@VMTest local]# chgrp -R mysql mysql/[root@VMTest local]# cd mysql/[root@VMTest mysql]# mkdir data
 
[ root@VMTest mysql]# chown -R mysql:mysql data

Seven, enter the mysql folder, and install mysql

# Enter mysql
[ root@VMTest etc]# cd /usr/local/mysql/
 
# Install mysql
[ root@VMTest mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/or(recommend):[root@VMTest mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/2018-07-0415:46:02[WARNING] 5mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2018- 07- 0415:46:05[ WARNING] The bootstrap log isn't empty:2018-07-0415:46:05[WARNING]2018-07-04T15:46:02.728710Z 0[Warning]--bootstrap is deprecated. Please consider using --initialize instead
2018- 07- 01 T15:46:02.729161Z 0[Warning] Changed limits: max_open_files:1024(requested 5000)2018-07-04 T15:46:02.729167Z 0[Warning] Changed limits: table_open_cache:407(requested 2000)
[ root@VMTest mysql]# cp ./support-files/mysql.server /etc/init.d/mysqld
[ root@VMTest mysql]# chown 777/etc/my.cnf
[ root@VMTest mysql]# chmod +x /etc/init.d/mysqld
  1. Create a my.cnf file under /etc
# enter/etc folder
[ root@VMTest mysql]# cd /etc
 
# Create my.cnf file
[ root@VMTest etc]# touch my.cnf
 
# Edit my.cnf
[ root@VMTest etc]# vim my.cnf

1 ) My.cnf add the following content:

[ mysql]
# Set the default character set of the mysql client
default-character-set=utf8
 
[ mysqld]
# Set 3306 port
port =3306
 
# Set mysql installation directory
basedir=/usr/local/mysql
 
# Set the storage directory of the mysql database data
datadir=/usr/local/mysql/data
 
# Maximum number of connections allowed
max_connections=200
 
# The character set used by the server defaults to the 8-bit encoding latin1 character set
character-set-server=utf8
 
# The default storage engine that will be used when creating new tables
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M

2 ) View the content of my.cnf

# View my.cnf file
[ root@VMTest mysql]# cat /etc/my.cnf

Nine, start mysql

# Start mysql
[ root@VMTest mysql]# /etc/init.d/mysqld start
or
[ root@VMTest mysql]# ./mysqld --defaults-file=/etc/my.cnf --user=root
MySQL manager or server PID file could not be found![FAILED]

solve:

# 1、 View process
[ root@VMTest mysql]# ps aux|grep mysql
root 100310.00.11132641616 pts/0 S 14:360:00/bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/iZ2ze3hm3gyjyjz628l7rgZ.pid
mysql 102200.019.11140876195072 pts/0 Sl 14:360:02/usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=iZ2ze3hm3gyjyjz628l7rgZ.err --pid-file=/usr/local/mysql/data/iZ2ze3hm3gyjyjz628l7rgZ.pid --port=3306
root 104210.00.0112660968 pts/0 R+15:510:00 grep --color=auto mysql
 
# 2、 Kill process
[ root@VMTest mysql]# kill -910031[root@VMTest mysql]# kill -910220
 
# 3、 Restart mysql
[ root@VMTest mysql]# /etc/init.d/mysqld restart
Shutting down MySQL..
Starting MySQL.

Ten, set to boot

# Set boot up
[ root@VMTest mysql]# chkconfig --level 35 mysqld on
[ root@VMTest mysql]# chkconfig --list mysqld
 
[ root@VMTest mysql]# chmod +x /etc/rc.d/init.d/mysqld
[ root@VMTest mysql]# chkconfig --add mysqld
[ root@VMTest mysql]# chkconfig --list mysqld
[ root@VMTest mysql]# service mysqld status
SUCCESS! MySQL running(4475)
  1. Modify the configuration file
# enter/etc/profile folder
[ root@VMTest mysql]# vim /etc/profile

1 ) Modify /etc/profile and add the following at the end

# modify/etc/profile file
# set mysql environment
export PATH=$PATH:/usr/local/mysql/bin
 
# Make the file effective
[ root@VMTest mysql]# source /etc/profile

Twelve, get mysql initial password

# 1、 Get mysql initial password
[ root@VMTest bin]# cat /root/.mysql_secret
# Password setfor user 'root@localhost' at 2017-04-1717:40:02
_ pB*3VZl5T<6
 
# 2、 change Password
[ root@VMTest bin]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with; or \g.
Your MySQL connection id is 53
Server version:5.7.22 MySQL Community Server(GPL)Copyright(c)2000,2018, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h'for help. Type '\c' to clear the current input statement.
 
mysql>set PASSWORD =PASSWORD('root');
Query OK,0 rows affected,1warning(0.00 sec)
 
mysql> flush privileges;
Query OK,0 rows affected(0.01 sec)
  1. Add remote access permissions
# Add remote access permissions
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-A
Database changed
 
mysql> update user set host='%' where user='root';
Query OK,0 rows affected(0.00 sec)
Rows matched:1 Changed:0 Warnings:0
 
mysql> select host,user from user;+-----------+---------------+| host | user |+-----------+---------------+|%| root || localhost | mysql.session || localhost | mysql.sys |+-----------+---------------+3 rows inset(0.00 sec)
  1. Restart mysql to take effect
# Restart mysql
[ root@VMTest bin]# /etc/init.d/mysqld restart
Shutting down MySQL..
Starting MySQL.

Remarks:

As installed in/usr/mysql under local, so mysql can be started in any folder
 
If it is installed in another folder, execute the following command:
# In order to log in to mysql in any directory
ln -s /Your mysql path/mysql /usr/local/mysql

15、 Verification, you may need to turn off the firewall

Service iptables stop

Recommended Posts

centos7 .*tar package to install MySQL5.7
How to install MySQL on CentOS 8
CentOS7.2 install Mysql5.7.13
CentOS7 install MySQL
CentOS install mysql
CentOS7 install mysql
CentOS 7 install MySQL 5.6
CentOS8 install MySQL8.0
CentOS7 install mysql8
CentOS7 install MySQL8
centos 7.5 install mysql5.7.17
CentOS7 system yum way to install MySQL5.7
Install MySQL5.7 in centos7
Install mysql5.7 under CentOS7
CentOS 7.2 Yum install MySQL 5.6
Centos7 install Mysql8 tutorial
Centos manually install mysql8
Centos7 install Mysql database
Linux (CentOS7) using RPM to install mysql 8.0.11 tutorial
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
centos install mysql through yum
Centos7.6 method to install Tomcat-8.5.39
CentOS8 install MySQL8 (pro test)
Centos 7 install jdk and package service service
How to install jdk1.8 on centOS7
CentOS7 yum install and start mysql
How to install MySQL on Ubuntu 20.04
CentOS Yum compile and install MySQL 5.6
How to install R on CentOS 8
How to install FFmpeg on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
[Introduction to redis] Install redis under Centos
CentOS 7 install Nginx, PHP, MySQL packages
How to install MySQL on Ubuntu 20.04
How to install TeamViewer on CentOS 8
How to install PHP7.4 in CentOS
How to install Gradle on CentOS 8
How to install Elasticsearch on CentOS 8
Install MySql with Docker in CentOS7
How to install Jenkins on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8
How to install mysql in Ubuntu 14.04
How to install Yarn on CentOS 8
How to install Nginx on CentOS 8
How to install Asterisk on CentOS 7
How to install Jenkins on CentOS 8
Install MySQL on Linux CentOS7 (Windows)
How to install Vagrant on CentOS 8
CentOS7 yum install and start mysql
Centos7 and centos8 install mysql5.6 5.7 8.0 so simple
Centos yum install mysql5.6 or above
How to install Skype on CentOS 8
How to install htop on CentOS 8
How to install Python on CentOS 8
How to install Elasticsearch on CentOS 8
How to install HDP2.6 in Centos7.2
How to install Postgresql on CentOS 8
How to install Wordpress on Centos
1.5 Install Centos7