Lamp environment builds Linux CentOS 6.5 compile and install MySQL 5.6

Keywords: MySQL cmake yum RPM

Detailed Installation of mysql in Lamp Environment of Classical web Development Portfolio

Pre-installation preparation

Check whether mysql has been installed on centos through the rpm command, and then uninstall the existing version of mysql

[root@localhost src]# rpm -qa|grep mysql
mysql-libs-5.1.66-2.el6_3.i686
[root@localhost src]# rpm -e --nodeps mysql-libs-5.1.66-2.el6_3.i686

 

Installing dependency packages required for mysql compilation through yum

[root@localhost src]# yum install gcc gcc-c++ perl

 

Download MySQL 5.6 installation package, MySQL 5.6 installation package download address: https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.36.tar.gz.

Add mysql user groups and users, as well as the installation directory of mysql

[root@localhost src]# groupadd mysql
[root@localhost src]# useradd -g mysql -s /sbin/nologin -M mysql
[root@localhost src]# mkdir /usr/local/mysql
[root@localhost src]# id mysql
uid=501(mysql) gid=501(mysql) groups=501(mysql)

 

Authorize the installation directory of mysql

[root@localhost src]# chown -R mysql.mysql /usr/local/mysql
[root@localhost src]# ll /usr/local
drwxr-xr-x. 2 mysql mysql 4096 May 11 09:09 mysql

 

Start installation

After decompression, mysql 5.6 has been configurated by cmake. It can be directly configurated by default cmake. It can also be configurated by itself. The following configuration can be executed by itself, modifying some conventional mysql configuration wellbore number # followed by annotations.

[root@localhost mysql-5.6.36]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \   #Specify installation directory
> -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \#Specify mysql.sock address
> -DDEFAULT_CHARSET=utf8 \#Specify the default character set
> -DDEFAULT_COLLATION=utf8_general_ci \#Specify the default sorted character set
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \#Install innodb storage engine
> -DWITH_MYISAM_STORAGE_ENGINE=1 \install myisam Storage Engine
> -DWITH_ARCHIVE_STORAGE_ENGINE=1 \install archive Storage Engine
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \install blackhole Storage Engine
> -DMYSQL_DATADIR=/usr/local/mysql/data \#mysql Data File Storage Directory
> -DMYSQL_TCP_PORT=3306 \#port
> -DENABLE_DOWNLOADS=1

 

After configuration, errors may occur

Tip error: Can NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)

 

Here's the hint that Curses can't be found. Install the library through yum

[root@localhost src]# yum -y install ncurses-devel

 

Then delete CMakeCache.txt and recreate cmake

[root@localhost mysql-5.6.36]# rm -rf CMakeCache.txt

 

After cmake, no error is reported and make & make install is executed directly

Install data files

After the installation of mysql, you need to install files. You can see mysql_install_db in the scripts folder under the installation directory of Mysql to install MySQL data files and specify MySQL users.

[root@localhost mysql]# ls /usr/local/mysql/scripts/
mysql_install_db
[root@localhost mysql]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

 

mysql start
[root@localhost mysql]# /usr/local/mysql/support-files/mysql.server start
Starting MySQL.. SUCCESS!

 

Log on to mysql

[root@localhost mysql]# /usr/local/mysql/bin/mysql -uroot

 

The first login does not require a password, so you need to set the root login password through mysqladmin.

[root@localhost mysql]# /usr/local/mysql/bin/mysqladmin -uroot password '111111'

 

View mysql configuration file

[root@localhost mysql]# /usr/local/mysql/bin/mysql --verbose --help |grep -A 1 'Default options'
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

 

You can see that mysql configuration files are stored in multiple locations, and the order of reading is

/etc/my.cnf ,/etc/mysql/my.cnf  ,/usr/local/mysql/etc/my.cnf ,~/.my.cnf

 

Then we can copy my-default.cnf configuration file from the support-files folder in the mysql installation directory to / etc/my.cnf.

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

 

If there is direct coverage, it's better to change the owner of / etc/my.cnf

Configuration of environmental variables, easy to use

Put mysql service startup under / etc/init.d /.

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

 

Add / usr/local/mysql/bin / directory to environment variables, vim editor vim /etc/profile Permanently adds environment variables, restart takes effect

export PATH=$PATH:/usr/local/mysql/bin

 

If you don't want to restart, you can also execute scripts after editing vim/etc/profile

[root@localhost support-files]# export PATH=$PATH:/usr/local/mysql/bin

 

In this way, the terminal will fail after it is shut down.

Original Link Address: http://www.17codes.com/archives/92

Posted by FuzziNectar on Mon, 01 Jul 2019 10:27:22 -0700