Build a Linux CentOS6.5 environment and compile and install mysql5.6 and centos6.5mysql5.6
Install mysql in a typical web development kit Lamp EnvironmentPreparations before installation
Run the rpm command to check whether mysql has been installed on centos and then uninstall an existing mysql version.
[root@localhost src]# rpm -qa|grep mysqlmysql-libs-5.1.66-2.el6_3.i686[root@localhost src]# rpm -e --nodeps mysql-libs-5.1.66-2.el6_3.i686
Install the required dependency package for mysql compilation through yum
[root@localhost src]# yum install gcc gcc-c++ perl
Download the mysql5.6 installation package and mysql5.6 installation package: 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 mysql installation directory
[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 mysqluid=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/localdrwxr-xr-x. 2 mysql mysql 4096 May 11 09:09 mysql
Start Installation
After decompression, mysql5.6 is configured through cmake. You can directly use the default cmake method. you can directly enter the configuration, or you can specify the configuration yourself, and then execute the configuration yourself, modify some general mysql configuration well numbers # The following is a comment
[Root @ localhost mysql-5.6.36] # cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \ # specify the installation directory>-DMYSQL_UNIX_ADDR =/usr/local/mysql. sock \ # specify mysql. sock address>-DDEFAULT_CHARSET = utf8 \ # specify the default Character Set>-DDEFAULT_COLLATION = utf8_general_ci \ # specify the default sorting Character Set>-DWITH_INNOBASE_STORAGE_ENGINE = 1 \ # Install innodb 1 \ install myisam storage engine>-plugin = 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.
Error message: cocould NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
The following message indicates that the Curses cannot be found. Use yum to install the library.
[root@localhost src]# yum -y install ncurses-devel
Delete cmakecache.txt and try cmake again.
[root@localhost mysql-5.6.36]# rm -rf CMakeCache.txt
Run make & make install
Install data files
After installing mysql, you need to install the file. In the scripts folder under the mysql installation directory, You can see mysql_install_db, which is used to install the mysql data file, specifying the mysql user
[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
Start mysql
[root@localhost mysql]# /usr/local/mysql/support-files/mysql.server startStarting MySQL.. SUCCESS!
Log on to mysql
[root@localhost mysql]# /usr/local/mysql/bin/mysql -uroot
No Password is required for the first login. You need to use mysqladmin to set the root login password,
[root@localhost mysql]# /usr/local/mysql/bin/mysqladmin -uroot password '111111'
View the 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
We can see that the mysql configuration file is stored in multiple locations, and the read order is
/etc/my.cnf 、/etc/mysql/my.cnf 、/usr/local/mysql/etc/my.cnf 、~/.my.cnf
Copy the my-default.cnf configuration file in the support-files folder under the mysql installation directory to/etc/my. cnf.
[root@localhost support-files]# cp my-default.cnf /etc/my.cnf
If there is direct overwriting, it is better to change/etc/my. cnf to the owner here.
Environment variable configuration for ease of use
Put mysql Service Startup under/etc/init. d/
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
Add the/usr/local/mysql/bin/directory to the environment variable. Run vim to edit vim/etc/profile to add the environment variable permanently. The restart takes effect.
export PATH=$PATH:/usr/local/mysql/bin
If you do not want to restart, you can run the script after editing vim/etc/profile.
[root@localhost support-files]# export PATH=$PATH:/usr/local/mysql/bin
In this way, the terminal will become invalid after it is disabled.
Original article link: http://www.17codes.com/archives/92