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

MySQL database Shell import_table data import

Table of contents MySQL Shell import_table data i...

Detailed tutorial on installing MySQL 8 in CentOS 7

Prepare Environmental information for this articl...

10 Tips to Improve Website Usability

Whether it is a corporate website, a personal blo...

WeChat applet implements waterfall flow paging scrolling loading

This article shares the specific code for WeChat ...

5 Tips for Protecting Your MySQL Data Warehouse

Aggregating data from various sources allows the ...

Install mysql5.7.13 using RPM in CentOS 7

0. Environment Operating system for this article:...

Tutorial on using the hyperlink tag in HTML

The various HTML documents of the website are con...

Install Memcached and PHP Memcached extension under CentOS

Regarding the high-performance distributed memory...

MySQL 5.7.19 (tar.gz) installation graphic tutorial under Linux

The first tutorial for installing MySQL-5.7.19 ve...

Detailed explanation of the use of this.$set in Vue

Table of contents Use of this.$set in Vue use Why...

Detailed explanation of Vue life cycle

Table of contents Why understand the life cycle W...

How to install MySQL 5.7.29 with one click using shell script

This article refers to the work of 51CTO blog aut...

Detailed explanation of mixins in Vue.js

Mixins provide distributed reusable functionality...