mysql-source code deployment

Why install from source?

Overview of source code compilation:

  • 1. Use the advantages of source code to install software to obtain the latest software version, fix bugs in time, and flexibly customize software functions according to user needs
  • 2. Examples of applications
  • When installing a newer version of an application,
    the latest version of free software is mostly released first in the form of source code
  • When the currently installed program cannot meet the needs, the
    compilation and installation can be modified and customized by the user.
  • When new functions need to be added to the application, the
    user can reconfigure, freely modify the source code, and add new functions

Undoubtedly, the source code installation does solve too many difficult questions in our work. There is source code, not to worry, choose source code, choose easy, choose source code, unlimited possibilities, free control

Operating environment:

Installation system: CentOS6.5_x64
Mysql version: mysql-5.6.38.tar.gz Environment
Cmake (cross-platform build tool): Install directly using yum

Operation before installation

Dependent package installation

[root@DB ~]# yum -y install gcc gcc-c++ ncurses-devel bison boost cmake

Add mysql user, if there is no
need to add

[root@DB ~]# useradd mysql
useradd: user 'mysql' already exists

Check whether there are mysql and mysql modification dependencies on the original system, and delete if there are.
You can see that mine is installed

[root@DB ~]# rpm -qa |grep mysql
qt-mysql-4.6.2-26.el6_4.x86_64
mysql-5.1.73-8.el6_8.x86_64
mysql-server-5.1.73-8.el6_8.x86_64
mysql-libs-5.1.73-8.el6_8.x86_64

If it cannot be deleted, as shown in the figure below--nodeps parameter forces it to be deleted

[root@DB ~]# rpm -e mysql-server --nodeps
[root@DB ~]# rpm -e mysql --nodeps
[root@DB ~]# rpm -e mysql-libs --nodeps

Start the installation of mysql software

I have uploaded the installation package, and I will start the operation directly
. Explanation: cmake. Means to perform cmake operation on the current directory
&& When the pre and post command statements are true, do and connect to use
. The default version is /usr/local/mysql

[root@DB ~]# ls
mysql-5.6.38.tar.gz
[root@DB ~]# tar xf mysql-5.6.38.tar.gz 
[root@DB ~]# cd mysql-5.6.38
[root@DB mysql-5.6.38]# cmake . && make && make install

After executing the above command, please wait patiently, a tea break for 10-20 minutes should be almost the same

MYSQL initialization

Give permission

[root@DB mysql-5.6.38]# chown -R mysql.mysql /usr/local/mysql/

Switch to /usr/local/mysql and initialize, the subsequent series of operations are in this directory

[root@DB mysql-5.6.38]# cd /usr/local/mysql/
[root@DB mysql]# scripts/mysql_install_db \
> --user=mysql \
> --basedir=/usr/local/mysql/ \
> --datadir=/usr/local/mysql/data/

Provide configuration files to mysql

[root@DB mysql]# cp support-files/my-default.cnf /etc/my.cnf

Make startup items

[root@DB mysql]# cp support-files/mysql.server /etc/init.d/mysqld

Make soft links to facilitate the use of mysql related commands

[root@DB mysql]# ln -s /usr/local/mysql/bin/* /usr/local/bin/

Add boot-up

[root@DB mysql]# chkconfig --add mysqld

Start and log in to mysql to test whether it is successful

[root@DB mysql]# service mysqld start

Successful login (log in directly, the default password below mysql5.7 is empty)

[root@DB mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.38 Source distribution

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

Well, the mysql source code installation is now complete!

Guess you like

Origin blog.csdn.net/qq_49296785/article/details/108522665