Tutorial on installing mysql under centos7

Tutorial on installing mysql under centos7

Recently, I plan to deploy a cloud disk on my home server, so I started a series of environment setup operations. When installing MySQL, I found some differences from before, so I wrote them down to avoid searching for problems like today next time.

1. Uninstall the old version

Use the following command to check whether MySQL Server is installed

rpm -qa | grep mysql

If yes, uninstall it with the following command

rpm -e mysql //Normal deletion mode rpm -e --nodeps mysql //Forced deletion mode. If you are prompted to delete other dependent files when using the above command, you can use this command to forcefully delete them.

Two: Install MySQL

1. Install dependencies

yum -y install make gcc-c++ cmake bison-devel ncurses-devel

2. Get the source code (in China, it is recommended to download from Sohu's mirror http://mirrors.sohu.com/mysql...
MySQL 5.7 requires the boost library. It is difficult to find a suitable version online. It is recommended to directly download the MySQL version with the boost library.

wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-boost-5.7.24.tar.gz
tar xvf mysql-boost-5.7.24.tar.gz
cd mysql-5.7.24

3. Compile and install

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/usr/local/mysql/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DDOWNLOAD_BOOST=1 -DWITH_BOOST=./boost
make && make install

For compilation parameters, please refer to http://dev.mysql.com/doc/refm....

Three: Configure MySQL

Use the following command to check whether there is a mysql user and user group

cat /etc/passwd #View the user list cat /etc/group #View the user group list

If not, create

groupadd mysql
useradd -g mysql mysql

Modify /usr/local/mysql permissions

chown -R mysql:mysql /usr/local/mysql
MySQL 5.7.18 and later no longer provides a default MySQL configuration file. Here we found a simple configuration on the Internet.
vi /etc/my.cnf and then write the following content [client]
port = 3306
default-character-set=utf8

[mysqld]
# General configuration options basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character-set-server=utf8
default_storage_engine = InnoDB

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Configure the service script cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on #Add to startup items service mysql start #Start mysql
Add the mysql executable file to the path directory, vi /etc/profile

PATH=/usr/local/mysql/bin:$PATH
export PATH

Then execute source /etc/profile

Four: Initialize mysql

1. Execute the initialization script (the last line of the initialization will generate the mysql root password, please record it, or you can use ./mysqld --initialize--insecure to initialize an account with an empty password)

cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
...
2019-04-11T14:34:15.922856Z 1 [Note] A temporary password is generated for root@localhost: /rTmud(Th5Yy

2. Open port 3306 on the firewall

The method of adding ports in Firewalld is as follows:

firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload

Summarize

The above is the tutorial on how to install MySQL under CentOS 7 introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • CentOS7 uses yum to install mysql 8.0.12
  • Detailed tutorial on installing MySQL 8.0 from source code on CentOS 7.4
  • Installation tutorial of mysql8.0rpm on centos7
  • How to install MySQL 5.7 from source code in CentOS 7 environment
  • Tutorial on installing lnmp using yum on centos7 (linux+nginx+php7.1+mysql5.7)
  • How to install mysql using dnf in CentOS7
  • Centos7 installation and configuration of Mysql5.7
  • How to install jdk1.8.0_151 and mysql5.6.38 in centos7.2.1511
  • Installation and configuration code of apache, php7 and mysql5.7 in CentOS7 server

<<:  js converts a multidimensional array into a one-dimensional array and then reorders it

>>:  Detailed explanation of whereis example to find a specific program in Linux

Recommend

Example code of CSS layout at both ends (using parent's negative margin)

Recently, during the development process, I encou...

Create a movable stack widget function using flutter

This post focuses on a super secret Flutter proje...

Upgrading Windows Server 2008R2 File Server to Windows Server 2016

The user organization has two Windows Server 2008...

Solve the problem of using swiper plug-in in vue

Since I used this plugin when writing a demo and ...

How to use Webstorm and Chrome to debug Vue projects

Table of contents Preface 1. Create a new Vue pro...

Express implements login verification

This article example shares the specific code for...

Nginx rush purchase current limiting configuration implementation analysis

Due to business needs, there are often rush purch...

Detailed explanation of chmod command usage in Linux

chmod Command Syntax This is the correct syntax w...

js uses the reduce method to make your code more elegant

Preface In actual projects, the most common proce...

In-depth explanation of slots and filters in Vue

Table of contents Slots What are slots? Slot Cont...

Simple web page code used in NetEase blog

How to use the code in NetEase Blog: First log in...

Method to detect whether ip and port are connectable

Windows cmd telnet format: telnet ip port case: t...

An article tells you how to write a Vue plugin

Table of contents What is a plugin Writing plugin...

How to Fix File System Errors in Linux Using ‘fsck’

Preface The file system is responsible for organi...