Redhat 8.2_cmake compile source code install MySQL5.7.14

Source installation!!!

After three nights of trials + for Baidu and CSDN, I finally concluded that I encountered various errors during the period and created 3 virtual machines. Finally, I concluded that there was no problem after two tests.
Second, I found that I wrote before Not easy to understand

0. First of all preparations, source code package

 mysql-boost-5.7.14.tar.gz

Download link https://downloads.mysql.com/archives/community/ and find the version you want
Insert picture description here

1. First create a directory
mkdir /soft
to store the package, and transfer the package to the soft root in Linux .
Using xfpttransfer, you can also directly shortcut keys in xshellctrl+alt+f

Drag the mysql-boost-5.7.14.tar.gz file into the virtual machine /soft/directory, and then enter the /softdirectory


2. Install development tools and development kits

yum install -y cmake gcc-c++* make ncurses-devel
yum install libaio libaio-devel openssl-devel -y
yum install perl-Data-Dumper -y
yum install net-tools vim -y

After the installation is complete, and no error is reported, proceed to the next step


3. After decompressing the file
, the directory where you are at this time must be the directory where the source file /softis located, that is, the directory where the file was just stored/soft
cd /soft/
tar xf mysql-boost-5.7.14.tar.gz -C /usr/local/src/


4. To mysqlcreate users and groups

groupadd -r -g 306 mysql
useradd -g 306 -r -u 306 mysql

5. cmake compile source code to install MySQL database
! ! ! ! ! ! !
Be sure to enter the directory where the file is decompressed first,
cd /usr/local/src/mysql-5.7.14/
and then execute the following codes in sequence

下面代码很长,不要少复制了
========
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL-USER=mysql \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=./boost
=========================================================================================
等待上面执行完
=========================================================================================
make -j 4 && make install

The length of the code must not be less copied
\

This waiting time is quite long, if it gets stuck, please turn off the virtual machine, and then set the configuration to 4G+4 cores (better than this)
and restart

===!!!重新执行就行了!!!但是一定要记得切换目录,要不然会报错===
cd /usr/local/src/mysql-5.7.14/
make -j 4 && make install   

The installation is complete and no error is reported, proceed to the next step


6. Change the folder owner and group

chown -R mysql.mysql /usr/local/mysql/

7. Initialize mysql, a random password will be given at the end of initialization

Initialization code

=========
/usr/local/mysql/bin/mysqld --initialize \
--user=mysql --datadir=/usr/local/mysql/data \
--basedir=/usr/local/mysql/
=========

The random password looks like the following, in the last line

root@localhost: FhvqcGRy9W#8

8. Provide the main configuration file for mysql

cd /usr/local/mysql/
\cp support-files/my-default.cnf /etc/my.cnf
================================
vim /etc/my.cnf
添加如下行指定mysql数据文件的存放位置

[mysqld]
datadir = /usr/local/mysql/data

Just change it to the picture like this
The picture of the city looks like this


9. Provide sysv service script for mysql

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld  --添加为系统服务
chkconfig mysqld on     --添加为系统服务

10. Modify the PATH environment variable so that the system can directly use mysql related commands

vim /etc/profile.d/mysql.sh
=========将下面这段内容写入保存
	export PATH=$PATH:/usr/local/mysql/bin
=========
!!!!!!!!!一定要做下面这步
source /etc/profile.d/mysql.sh  这个是为了现在应用环境

Insert picture description here


Start MySQL

systemctl start mysqld

=========================================================================================

查看MySQL运行状态

systemctl status mysqld.service  --如果为active则表示MySQL已经运行了
或者
systemctl is-active mysql.service   --显示为active也是启动了

So far, all installation is complete


11. If you don’t remember the random password, you can check it with the following method. If you can’t check it, there is a high probability that the initialization was not successful. It is recommended to reinstall it.

默认有个随机密码:
more /var/log/mysql.log
也可以使用grep命令查询密码:
grep 'temporary password' /var/log/mysqld.log

Guess you like

Origin blog.csdn.net/weixin_46049759/article/details/115312723