Detailed tutorial on using cmake to compile and install mysql under linux

Detailed tutorial on using cmake to compile and install mysql under linux

1. Install cmake

1. Unzip the cmake compressed package

[root@mysql tools]# tar -zvxf cmake-2.8.8.tar.gz
[root@mysql tools]# ls
cmake-2.8.8 cmake-2.8.8.tar.gz mysql-5.5.16.tar.gz scripts

2. Analysis

[root@mysql tools]# cd cmake-2.8.8
[root@mysql cmake-2.8.8]# ./configure
---------------------------------------------
CMake 2.8.8, Copyright 2000-2009 Kitware, Inc.
Found GNU toolchain
C compiler on this system is: gcc
C++ compiler on this system is: g++
Makefile processor on this system is: gmake
g++ is the GNU compiler
g++ has STL in std:: namespace
g++ has ANSI streams
g++ has streams in std:: namespace

3. Installation

[root@mysql cmake-2.8.8]# echo $?
0
#If the return value is 0, the execution is successful, if the return value is 1, the execution fails;

[root@mysql cmake-2.8.8]# gmake && gmake install
Scanning dependencies of target cmIML_test
[ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test.co
[ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_ABI_C.co
[ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_INT_C.co
[ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_include_C.co
[ 2%] Building CXX object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_ABI_CXX.cxx.o
[ 2%] Building CXX object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_INT_CXX.cxx.o
[ 2%] Building CXX object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_include_CXX.cxx.o

2. Start installing MySQL

1. First, you need to install the (ncurses-devel) dependency package

[root@mysql cmake-2.8.8]# cd …
[root@mysql tools]# yum -y install ncurses-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

base: mirrors.zju.edu.cn
extras: centos.ustc.edu.cn
updates: mirrors.zju.edu.cn
Resolving Dependencies
–> Running transaction check
—> tools ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 will be installed
#############Check after installation is complete###########
[root@mysql tools]# rpm -qa | grep ncurses-devel
ncurses-devel-5.9-14.20130511.el7_4.x86_64
[root@mysql tools]#

2. Unzip the mysql compressed package

[root@mysql tools]# tar -zvxf mysql-5.5.16.tar.gz
[root@mysql tools]# ls
cmake-2.8.8 cmake-2.8.8.tar.gz mysql-5.5.16 mysql-5.5.16.tar.gz scripts
[root@mysql tools]#

3. Create a virtual user

[root@mysql tools]# useradd mysql -s /sbin/nologin -M
[root@mysql tools]# id mysql
uid=1000(mysql) gid=1000(mysql) groups=1000(mysql)
[root@mysql tools]#

4. Configuration analysis

[root@mysql tools]# cd mysql-5.5.16
[root@mysql mysql-5.5.16]#
[root@mysql mysql-5.5.16]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.16 -DMYSQL_DATADIR=/usr/local/mysql-5.5.16/data -DMYSQL_UNIX_ADDR=/usr/local/mysql-5.5.16/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 -DWITH_FAST_MUTEXES=1 -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DWITH_DEBUG=0

5. Installation

[root@mysql mysql-5.5.16]# make && make install
Scanning dependencies of target INFO_BIN
[ 0%] Built target INFO_BIN
Scanning dependencies of target INFO_SRC
[ 0%] Built target INFO_SRC
Scanning dependencies of target abi_check
[ 0%] Built target abi_check
Scanning dependencies of target zlib

6. Create a soft link

[root@mysql mysql-5.5.16]# ln -s /usr/local/mysql-5.5.16/ /usr/local/mysql
[root@mysql mysql-5.5.16]# readlink /usr/local/mysql
/usr/local/mysql-5.5.16/
[root@mysql mysql-5.5.16]#

7. Configure the environment

[root@mysql mysql-5.5.16]# cd …
[root@mysql tools]# echo 'export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile

[root@mysql tools]# tail -1 /etc/profile
export PATH=/usr/local/mysql/bin:$PATH

[root@mysql tools]# source /etc/profile
[root@mysql tools]# echo $PATH
/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@mysql tools]#

8. Copy, view, set owner, and add tmp permissions

[root@mysql tools]# \cp mysql-5.5.16/support-files/my-small.cnf /etc/my.cnf
[root@mysql tools]# ll /usr/local/mysql/data/
total 0
drwxr-xr-x 2 root root 20 May 31 11:51 test
[root@mysql tools]# chown -R mysql.mysql /usr/local/mysql/data/
[root@mysql tools]# chmod -R 1777 /tmp/
[root@mysql tools]#

9. Initialize the database

[root@mysql tools]# cd /usr/local/mysql/scripts/
[root@mysql scripts]# ./mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql
Installing MySQL system tables…
OK
Filling help tables…
OK

Note: Seeing two OKs indicates success

10. Set up startup

[root@mysql scripts]# cd /roottools/mysql-5.5.16
[root@mysql mysql-5.5.16]# cp support-files/mysql.server /etc/init.d/mysqld
[root@mysql mysql-5.5.16]# chmod -R 755 /etc/init.d/mysqld
[root@mysql mysql-5.5.16]# chkconfig --add mysqld
[root@mysql mysql-5.5.16]# chkconfig mysqld on
[root@mysql mysql-5.5.16]# chkconfig --list mysqld

Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.

If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mysql mysql-5.5.16]#

11. Start the MySQL database

[root@mysql mysql-5.5.16]# /etc/init.d/mysqld start
Starting MySQL… SUCCESS!
[root@mysql mysql-5.5.16]#

12. Check the port process

[root@mysql mysql-5.5.16]# lsof -i:3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 51146 mysql 10u IPv4 82600 0t0 TCP :mysql (LISTEN)
[root@mysql mysql-5.5.16]# netstat -lnutp|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0: LISTEN 51146/mysqld
[root@mysql mysql-5.5.16]# ps -ef|grep 3306
mysql 51146 50900 0 14:13 pts/1 00:00:00 /usr/local/mysql-5.5.16/bin/mysqld --basedir=/usr/local/mysql-5.5.16 --datadir=/usr/local/mysql-5.5.16/data --plugin-dir=/usr/local/mysql-5.5.16/lib/plugin --user=mysql --log-error=/usr/local/mysql-5.5.16/data/mysql.err --pid-file=/usr/local/mysql-5.5.16/data/mysql.pid --socket=/usr/local/mysql-5.5.16/tmp/mysql.sock --port=3306
root 51170 16240 0 14:14 pts/1 00:00:00 grep --color=auto 3306
[root@mysql mysql-5.5.16]#

Note: If you want to reinitialize, just delete the data directory library file storage location or create a new library file storage location, reinitialize, and two OK prompts indicate success

Enter the database

[root@localhost ~]# mysql

View All Users

mysql> use mysql
mysql> show tables;
mysql> select user,host from user;

Delete the system default

delete from mysql.user where user='';
delete from mysql.user where host='::1';
select user,host from mysql.user;

Keep only these two

mysql> select user,host from mysql.user;
±-----±----------+
| user | host |
±-----±----------+
| root | 127.0.0.1 |
| root | localhost |
±-----±----------+
2 rows in set (0.00 sec)

mysql>
#########################

Adding additional authorized administrator users

grant all privileges on . to system@'192.168.%' identified by 'system' with grant option;

Character set path

vi /etc/locale.conf #centos7

mysql create password

/application/mysql//bin/mysqladmin -u root password '123456'

mysql change password

/application/mysql//bin/mysqladmin -u root -p123456 password '112233'

Summarize

The above is a detailed tutorial on how to use cmake to compile and install MySQL under Linux. I hope it will be helpful to you. If you have any questions, please leave me a message and I 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:
  • Detailed explanation of MySQL precompilation function
  • In-depth understanding of mysqli preprocessing compilation
  • Detailed tutorial on compiling and installing MySQL 8.0.20 from source code
  • Detailed tutorial on how to compile and install mysql8.0.29 in CentOS8 deployment LNMP environment
  • Understanding MySQL precompilation in one article

<<:  js detects keywords in the title and description and replaces or jumps to other pages when found

>>:  Summary of MySQL Architecture Knowledge Points

Recommend

A brief summary of my experience in writing HTML pages

It has been three or four months since I joined Wo...

Solution to Vue data assignment problem

Let me summarize a problem that I have encountere...

Handwriting implementation of new in JS

Table of contents 1 Introduction to the new opera...

Share 12 commonly used Loaders in Webpack (Summary)

Table of contents Preface style-loader css-loader...

A brief discussion on four solutions for Vue single page SEO

Table of contents 1.Nuxt server-side rendering ap...

A brief discussion on MySQL large table optimization solution

background The amount of new data in the business...

MySQL compressed package version zip installation configuration method

There are some problems with the compressed versi...

Nginx proxy axios request and precautions

Preface I recently wrote a small demo. Because I ...

Three ways to achieve background blur in CSS3 (summary)

1. Normal background blur Code: <Style> htm...

Use of js optional chaining operator

Preface The optional chaining operator (?.) allow...

Modification of the default source sources.list file of ubuntu20.04 LTS system

If you accidentally modify the source.list conten...

JavaScript to add and delete messages on the message board

This article shares a small example of adding and...

MySQL concurrency control principle knowledge points

Mysql is a mainstream open source relational data...

Detailed examples of the difference between methods watch and computed in Vue.js

Table of contents Preface introduce 1. Mechanism ...