Tutorial on binary compilation and installation of MySql centos7 under Linux

Tutorial on binary compilation and installation of MySql centos7 under Linux

// It took me a whole afternoon to install this, so I wrote a note to record it;

//If there are any problems, we can discuss them together (qq: 2970911340, email [email protected]), this is also my first time to write a blog to practice

1. Install cmake tool

# yum install -y cmake

2. Create mysql user

#useradd -s /sbin/nologin mysql //設置為非登陸用戶(安全)

3. Create a data directory. This directory is used for libraries, tables, logs, etc. generated when the database is initialized. Do not store things directly in this directory.

# mkdir -p /mysql/data //The directory name is arbitrary (it must correspond when setting it later), but the remaining space of the partition where the directory is located cannot be less than 1g (not very clear)
# chown mysql.mysql /mysql/ -R // Set the owner and group of the directory to mysql

4. Install the development packages required for compilation, etc.

# yum install ncurses-devel openssl-devel gcc* -y

5. Unzip the mysql binary package and compile

# cd /packet //cd to the directory where the package is stored# tar xvf mysql-5.6.22.tar.gz
# cd mysql-5.6.22
// Start compiling directly. Note: Be sure to enter the unzipped mysql package before editing. Then cmake takes a lot of parameters, some of which can be omitted #cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mysql/data -DDEFAULT_CHARSET=utf8 -DEXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_SSL=bundled
// -DCMAKE_INSTALL_PREFIX=/usr/local/mysql //Specify the installation directory //-DMYSQL_DATADIR=/mysql/data //Specify the data directory, the one created above //Others are omitted. . .

6. Error resolution (generally speaking, there will be no mistakes if you follow the above steps)

 # rm -rf CMakeCache.txt 
//When a compilation error occurs, be sure to delete CMakeCache.txt and then recompile. This file will automatically generate a "ledger" to record some compilation information. . .

//The error list will be put aside for now and updated later. . .

7. Installation

# make -j 4 // -j 4 uses 4 cores to compile. Because the compilation takes a long time, give it a few more u
# make install

8. Initialization

 # yum install -y perl-Data-Dumper //Will prompt to install this# /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/mysql/data/ --basedir=/usr/local/mysql
//After initialization, you can see the generated basic library and logs in the /mysql/data/ directory. // The client21.err (hostname.err) will record the logs when the mysql service is started, restarted, and shut down. If there is a problem with the startup, you can check the log # tail -50 /mysql/data/client21.err

9. Start configuration, start

# cp /usr/local/mysql/mysql-test/include/default_my.cnf /etc/my.cnf //This file is the configuration file for the mysql service# cat > /etc/my.cnf //Delete all the contents inside, otherwise there will be problems later. You can also add some options yourself# /usr/local/mysql/bin/mysqld_safe --user=mysql & //Start in the background. If you don't add '&', the current terminal will be useless. You can try it

//Of course, there may be some annoying errors in the middle, and I will update it later when I have time...

Eg: Check the prompt information, the address of the error log, where to start

1. Is selinux disabled? //setenforce 0 temporarily disabled

2. Is the initialization normal?

3. Is the data path 'datadir' in the /etc/my.cf configuration file of cp correct?

10. Define the command as a system command (you can ignore this step)

 # vim /etc/profile.d/mysql.sh
   export PATH=/usr/local/mysql/bin:$PATH //Just add this line# source /etc/profile.d/mysql.sh

11. Set up startup

# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# chkconfig --add mysqld //Add mysqld to the startup managed by chkconfig # chkconfig --list | grep mysqld //Check whether mysqld is started at each run level mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

And after setting it up, you can directly use systemctl restart | start mysqld to control it. (stop does not work, I don't know why yet, you can use 'pkill mysqld' instead)

12. Test access locally, download the MySQL client (not the service) on this local machine

# yum install -y mysql //This is the mariadb client, the experience will be better than my mysql, in fact, they are the same # mysql //Go directly and test if there is any problem

//If it can read and write normally, there is no problem, very good!

Summarize

The above is the tutorial on binary compilation and installation of MySql centos7 under Linux 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:
  • mysql-5.7.28 installation tutorial in Linux
  • Detailed tutorial on using cmake to compile and install mysql under linux
  • How to configure Java environment variables in Linux system
  • Installation and configuration of Java environment variables under Linux
  • Detailed steps for installing Java and configuring environment variables in Linux CentOS 7.0
  • Detailed graphic explanation of installing MySQL database and configuring Java project on Linux

<<:  Mini Program to Implement Paging Effect

>>:  WeChat applet realizes the effect of shaking the sieve

Recommend

Detailed explanation of where the images pulled by docker are stored

The commands pulled by docker are stored in the /...

Solution to ERROR 1366 when entering Chinese in MySQL

The following error occurs when entering Chinese ...

Vue uses vue meta info to set the title and meta information of each page

title: vue uses vue-meta-info to set the title an...

img usemap attribute China map link

HTML img tag: defines an image to be introduced in...

Sharing tips on using vue element and nuxt

1. Element time selection submission format conve...

JavaScript countdown to close ads

Using Javascript to implement countdown to close ...

CSS3 achieves flippable hover effect

CSS3 implements a flippable hover effect. The spe...

How to use limit_req_zone in Nginx to limit the access to the same IP

Nginx can use the limit_req_zone directive of the...

Install Docker on Linux (very simple installation method)

I have been quite free recently. I have been doin...

Detailed process of zabbix monitoring process and port through agent

Environment Introduction Operating system: centos...

Sample code for making a drop-down menu using pure CSS

Introduction: When I looked at interview question...

Architecture and component description of docker private library Harbor

This article will explain the composition of the ...

15-minute parallel artifact GNU Parallel Getting Started Guide

GNU Parallel is a shell tool for executing comput...

Introduction to HTML link anchor tags and their role in SEO

The <a> tag is mainly used to define links ...