Three common ways to install MySQL

  • 2020-11-18 06:30:45
  • OfStack

directory

There are three common ways to install MySQL:

rpm package form

General 2 base form

The source code to compile

1. rpm package form

(1) Provided by the operating system publisher

(2) MySQL official (version updates, fixes the more common BUG) www. mysql. com/downloads

An introduction to the rpm package types in MySQL:

MySQL-client client component
MySQL-debuginfo debugging MySQL components
MySQL-devel wants to compile and install packages such as PHP that depend on MySQL for MySQL
Embedded version of MySQL-embedded MySQL
MySQL - server Shared library
MySQL - shared Shared library
MySQL-shared-dompat for compatibility with older versions of Shared libraries
MySQL-test MySQL Test Components (online processing function)

Installation method:

First of all, you can download the corresponding version of rpm package from the installation CD or mysql's website as follows:

MySQL-server-community-5.5.28-1.rhel5.i386.rpm
MySQL-client-community-5.5.28-1.rhel5.i386.rpm

Then we can use the rpm command to install:

rpm -ivh MySQL-server-community-5.5.28-1.rhel5.i386.rpm
rpm -ivh MySQL-client-community-5.5.28-1.rhel5.i386.rpm

Add 1 point:

-ES90en displays the installation progress using the symbol #
-v reports on each step of the operation

2. Universal base 2 package

(1) The new user runs the process in a safe way:


 groupadd -r mysql 
 useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql 
 chown -R mysql:mysql /mydata/data 

(2) Install and initialize mysql-5.5.28

Download mysql version of platform corresponding to the local, this is a 32-bit platform, therefore, selected for mysql - 5.5.28 - linux2. 6 - i686. tar. gz


tar xf mysql-5.5.28-linux2.6-i686.tar.gz -C /usr/local 
 cd /usr/local/ 
 ln -sv mysql-5.5.28-linux2.6-i686 mysql 
 cd mysql 
 chown -R mysql:mysql . 
 scripts/mysql_install_db --user=mysql --datadir=/mydata/data 
 chown -R root . 

(3) Provide the master configuration file for mysql:


 cd /usr/local/mysql 
 cp support-files/my-large.cnf /etc/my.cnf 

(4) Modify the configuration file:

Modify the value of thread_concurrency in this file to multiply your CPU number by 2. For example, use the following line here:

thread_concurrency = 2

You also need to add the following line to specify the location of the mysql data file:

datadir = /mydata/data

(5) Provide sysv service script for mysql:


cd /usr/local/mysql 
 cp support-files/mysql.server /etc/rc.d/init.d/mysqld 

(6) Add to the list of services:


 chkconfig --add mysqld 
 chkconfig mysqld on 

(7) Then you can start the service test usage.


service mysqld start

3, source code compilation

(The installation compilation mode has changed a little, and the configuration process has not changed much, so I won't go into the details of each step later.)
MySQL must be installed with a cross-platform compiler, cmake, to compile source code on the 5.0 series of Red Hat systems

So:

(1) Install cmake first

make is required to install cmake


 tar xf cmake-...tar.gz 
 cd cmake-.. 
 ./bootstrap   Use this script to detect the compilation environment  
 make 
 make install 

(2) Compile and install mysql-5.5.28

Use cmake to compile mysql-5.5.28. The options have been changed.

cmake specifies compilation options differently from make, which is implemented as follows:

cmake .

cmake. -LH or ccmake. Find the relevant options you can use

Common options for specifying the installation path of an installation file:

-DCMAKE_INSTALL_PREFIX =/usr/local/mysql specifies the installation path
-DMYSQL_DATADIR=/data/mysql data installation path
-DSYSCONFDIR=/etc configuration file installation path

Since MySQL supports many storage engines, storage engines compiled by default include: csv, myisam, myisammrg, and heap. To install another storage engine, you can use a compilation option similar to the following:

-DWITH_INNOBASE_STORAGE_ES215en =1 Install the INNOBASE storage engine
-DWITH_ARCHIVE_STORAGE_ENGINE=1 Install the ARCHIVE storage engine
-DWITH_BLACKHOLE_STORAGE_ES227en =1 Install the BLACKHOLE storage engine
-DWITH_FEDERATED_STORAGE_ENGINE=1 Install the FEDERATED storage engine

To specify explicitly not to compile a storage engine, you can use an option similar to the following:

-DWITHOUT_ < ENGINE > _STORAGE_ENGINE=1

Such as:

-DWITHOUT_ES250en_ES251en_ENGINE =1 Do not enable or compile the EXAMPLE storage engine
-DWITHOUT_FEDERATED_STORAGE_ENGINE=1
-DWITHOUT_PARTITION_STORAGE_ENGINE=1

If you want to compile into other features, such as SSL, you can use options like the following to compile with or without a library:

-DWITH_READLINE=1
-DWITH_ES266en =system means to use the SSL library that comes with the system
-DWITH_ZLIB=system
-DWITH_LIBWRAP=0

Other common options:

-DMYSQL_TCP_PORT=3306 to set the default port
-DMYSQL_UNIX_ES283en =/tmp/ mysql.ES286en MySQL Socket position for interprocess communication
-DENABLED_LOCAL_INFILE=1 Whether to start local LOCAL_INFILE
-DEXTRA_CHARSETS=all which additional character sets are supported
-DDEFAULT_CHARSET=utf8 default Character set
-DDEFAULT_COLLATION=utf8_general_ci Default character set collation
-DWITH_DEBUG=0 Whether DEBUG function is enabled
-DENABLE_PROFILING=1 whether performance analysis is enabled

If you want to clean up the files generated by the previous compilation, you need to use the following command:

make clean
rm CMakeCache.txt

Compile the installation


tar xf mysql-5.5.28.tar.gz 
 cd mysql-5.5.28 
 groupadd -r mysql 
 useradd -g -r mysql mysql 
 mkdir -pv /data/mydata 
 chown -R mysql:mysql /data/mydata 
 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mydata -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci 
 make 
 make install
 cd /usr/local/mysql 
 chown -R :mysql .  Change belongs to the group  
 scripts/mysql_install_db --user=mysql --datadir=/data/mydata/  Specifies where to store the data 
 cp support-files/my-large.cnf /etc/my.cnf   Create configuration file  

Edit configuration file

vim /etc/my.cnf

Add the following line to specify the location of the mysql data file:

datadir = /mydata/data

Create the execution script and start the service


cp support-files/mysql.server /etc/rc.d/init.d/mysqld  Copy the script  
 chmod +x /etc/rc.d/init.d/mysqld  Execute permissions  
 chkconfig -add mysql  Add to the list of services  
 service mysqld start   Start the service  
 bin/mysql     Start the mysql 

These are the three common ways to install MySQL. I hope you enjoy it.


Related articles: