There are three common ways to install MySQL:
RPM Package Form
Universal binary Form
Source code Compilation
1,rpm Package Form
(1) The operating system publisher provides
(2) MySQL official (version updated, fixed more common bugs) www.mysql.com/downloads
Introduction to the RPM package types in MySQL:
Mysql-client Client Components
Mysql-debuginfo Debugging Components for MySQL
Mysql-devel wants MySQL-dependent component packages for MySQL compilation and installation of PHP
mysql-embedded MySQL embedded version
Mysql-server Shared libraries
Mysql-shared Shared libraries
Mysql-shared-dompat in order to be compatible with older versions of shared libraries
Mysql-test MySQL test kit (online processing function)
Installation method:
You can start by downloading the corresponding version of the RPM package from the installation CD or from the MySQL website as follows:
mysql-server-community-5.5.28-1.rhel5.i386.rpm
mysql-client-community-5.5.28-1.rhel5.i386.rpm
We can then 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 one point:
-H Use symbol # to display installation progress
-V reports the situation of each step of the operation
2, Universal binary Package
(1) The new user runs the process in a secure manner:
?
123 |
groupadd -r mysql useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql chown -R mysql:mysql /mydata/data |
(2) Installation and initialization of mysql-5.5.28
First download the MySQL version of the platform to local, here is the 32-bit platform, so the choice is mysql-5.5.28-linux2.6-i686.tar.gz
?
1234567 |
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 main configuration file for MySQL:
?
12 |
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 by multiplying your number of CPUs by 2, for example using the following line:
Thread_concurrency = 2
Also add the following line to specify where the MySQL data file will be stored:
DataDir =/mydata/data
(5) Provide SYSV service script for MySQL:
?
12 |
cd /usr/ local /mysql cp support-files/mysql.server /etc/rc.d/init.d/mysqld |
(6) Add to Service list:
?
12 |
chkconfig --add mysqld chkconfig mysqld on |
(7) You can then start the service test using.
?
3, source code compilation
(The installation of the compilation method A little change, the configuration process is not too much change, so the next step does not describe the various steps)
To compile the source code on the 5.0 series Red Hat system MySQL must use a cross-platform compiler CMake
So:
(1) First install CMake
Installing CMake requires make
?
12345 |
tar xf cmake-...tar.gz cd cmake-.. ./bootstrap 使用此脚本来检测编译环境 make make install |
(2) Compile and install mysql-5.5.28
Using CMake to compile mysql-5.5.28, the options are changed in a simple way ...
CMAKE specifies compilation options in a different way from make, which is implemented as follows:
CMake.
CMake. -lh or Ccmake. Find relevant options that you can use
Specifies the options that are commonly used when installing the installation path of a file:
-dcmake_install_prefix=/usr/local/mysql Specifying the installation path
-dmysql_datadir=/data/mysql Data Installation path
Installation path of the-DSYSCONFDIR=/ETC configuration file
Because MySQL supports a lot of storage engines, the default compiled storage engine includes: CSV, MyISAM, MYISAMMRG, and heap. To install additional storage engines, you can use a compilation option similar to the following:
-dwith_innobase_storage_engine=1 Installing the Innobase storage engine
-dwith_archive_storage_engine=1 Installing the ARCHIVE storage engine
-dwith_blackhole_storage_engine=1 Installing the Blackhole storage engine
-dwith_federated_storage_engine=1 Installing the Federated Storage Engine
To explicitly specify that a storage engine is not compiled, you can use an option similar to the following:
-dwithout_<engine>_storage_engine=1
Like what:
-dwithout_example_storage_engine=1 does not enable or not compile the EXAMPLE storage engine
-dwithout_federated_storage_engine=1
-dwithout_partition_storage_engine=1
If you want to compile into other functions, such as SSL, you can use a library similar to the following, or do not use a library when compiling:
-dwith_readline=1
-dwith_ssl=system represents the use of the SSL library that comes with the system
-dwith_zlib=system
-dwith_libwrap=0
Other common options:
-dmysql_tcp_port=3306 Setting the default port
-dmysql_unix_addr=/tmp/mysql.sock the location of the socket for MySQL interprocess communication
-denabled_local_infile=1 whether to start the local local_infile
What additional character sets are supported by-dextra_charsets=all
-ddefault_charset=utf8 Default Character Set
-ddefault_collation=utf8_general_ci Default Character Set collation
-dwith_debug=0 whether to start the DEBUG function
-denable_profiling=1 whether the profiling feature 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
Compiling the installation
?
12345678910111213 |
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 . 更改属组
scripts/mysql_install_db
--user=mysql --datadir=/data/mydata/ 指定数据存放位置
cp support-files/my-large.cnf /etc/my.cnf 创建配置文件
|
Editing a configuration file
Vim/etc/my.cnf
Add the following line to specify where the MySQL data files are stored:
DataDir =/mydata/data
Creating execution scripts and starting services
?
12345 |
cp support-files/mysql.server /etc/rc.d/init.d/mysqld 复制脚本 chmod +x /etc/rc.d/init.d/mysqld 执行权限 chkconfig - add mysql 添加到服务列表中 service mysqld start 启动服务 bin/mysql 启动mysql |
MySQL Database installation