Installing MySQL 5.7 under CentOS 6.5

Source: Internet
Author: User

Environment:

1), Hardware and software: E6420 dual core cpu,8g memory, 1T HDD

2), Virtual machine under CentOS 6.5 64-bit minimized desktop installation (1 cpu,2 cores, 2G memory, 35G HDD)

3), the installation package is placed in the/usr/local/src/lamp directory

1. Yum Install the compilation environment

[Email protected] ~]# yum-y install make gcc gcc-c++ zlib-devel Libaio

2, configure the firewall, open 80 ports, 3306 ports

[Email protected] ~]# Vi/etc/sysconfig/iptables

Join the line
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT #允许80端口通过防火墙

Finally reboot the firewall to make the configuration effective

[Email protected] ~]#/etc/init.d/iptables restart


3. Turn off SELINUX

[Email protected] ~]# Vi/etc/selinux/config

The detailed modifications are as follows:

#SELINUX =enforcing #注释掉

#SELINUXTYPE =targeted #注释掉

Selinux=disabled #增加

[[email protected] ~]# shutdown-r now # reboot system

4. Download and install CMake

[Email protected] ~]# Cd/usr/local/src/lamp
[Email protected] lamp]# TAR-ZXVF cmake-3.0.2.tar.gz
[Email protected] lamp]# CD cmake-3.0.2
[Email protected] cmake-3.0.2]#./bootstrap
[Email protected] cmake-3.0.2]# Gmake
[[email protected] cmake-3.0.2]# make
[[email protected] cmake-3.0.2]# make install

5. Yum Installation Ncurses-devel

[Email protected] ~]# yum-y install Ncurses-devel

6. Create users, groups, and directories

[[email protected] lamp]# groupadd mysql//Add group
[[email protected] lamp]# useradd mysql-g MySQL     //Add user
[[email protected] lamp]# passwd mysql      //Modify Password
[[email protected] lamp]# mkdir/usr/local/mysql        //mysql installation directory
[[email protected] lamp]# mkdir/usr/local/mysql/data//mysql Data Directory
[[email protected] LAMP]# chown-r Mysql.mysql/usr/local/mysql//Set

7. Compile and install mysql-5.7.5
[Email protected] ~]# Cd/usr/local/src/lamp
[Email protected] lamp]# TAR-ZXVF mysql-5.7.5-m15.tar.gz
[Email protected] lamp]# CD MYSQL-5.7.5-M15
[Email protected] mysql-5.7.5-m15]# cmake-dcmake_install_prefix=/usr/local/mysql-dmysql_unix_addr=/usr/local/ Mysql/mysql.sock-dmysql_datadir=/usr/local/mysql/data-ddefault_charset=utf8-ddefault_collation=utf8_general_ci -dwith_extra_charsets:string=utf8,gbk-dwith_myisam_storage_engine=1-dwith_innobase_storage_engine=1-dwith_ memory_storage_engine=1-dwith_readline=1-denabled_local_infile=1-dmysql_user=mysql-dmysql_tcp_port=3306- Ddownload_boost=0-dwith_boost=/usr/local/src/lamp
[[email protected] mysql-5.7.5-m15]# make
[[email protected] mysql-5.7.5-m15]# make install


  Note: If the first configuration error, you need to first delete the current MySQL source directory CMakeCache.txt, and then re-cmake configuration.

CMake parameter Description:

-dcmake_install_prefix= database program installation path;

-dmysql_datadir= Database File storage path (if not configured, $prefix_dir/data will be created by default)

-dmysql_unix_addr= The default location is/var/lib/mysql/mysql.sock, if you specify a different path, you need to make a soft link or set it in the profile my.cnf.

-ddefault_charset= Default Database encoding

-ddefault_collation= default database Grooming encoding-dwith_extra_charsets= Extended Support encoding (all | utf8,gbk,gb2312 | none)

-dwith_myisam_storage_engine= MYISAM engine Support (1|0)

-dwith_innobase_storage_engine= InnoDB engine Support (1|0)

-dwith_memory_storage_engine= MEMORY engine Support (1|0)

8. Permission settings:

[Email protected] ~]# Cd/usr/local/mysql

[Email protected] mysql]# chown-r root.mysql.

[Email protected] mysql]# chown-r mysql.mysql./data

9. Modify the configuration file my.cnf

[Email protected] mysql]# VI/ETC/MY.CNF

The configuration is as follows:

[Mysqld]
Basedir=/usr/local/mysql
Datadir=/usr/local/mysql/data
Log-error=/usr/local/mysql/mysql_error.log
Pid-file=/usr/local/mysql/mysql.pid

Socket=/usr/local/mysql/mysql.sock
User=mysql
port=3306
Explicit_defaults_for_timestamp=true
# Disabling Symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0

[Mysqld_safe]
Basedir=/usr/local/mysql
Datadir=/usr/local/mysql/data
Log-error=/usr/local/mysql/mysql_error.log
Pid-file=/usr/local/mysql/mysql.pid

10. Initialize the database

[Email protected] ~]# Cd/usr/local/mysql/bin
[Email protected] bin]#/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data

11, set the MYSQLD boot

[Email protected] ~]# Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysql
[Email protected] ~]# chmod 775/etc/init.d/mysql
[[email protected] ~]# chkconfig MySQL on
[Email protected] ~]# Shutdown-r now

12. Change the root password

[[Email protected] ~]# service MySQL stop
[Email protected] ~]# Rm/var/lock/subsys/mysql
[Email protected] ~]# chown-r mysql.mysql/usr/local/mysql/
[Email protected] ~]# Cd/usr/local/mysql/bin
[Email protected] bin]#/mysqld_safe--user=mysql--skip-grant-tables &//End With Ctr+c
[Email protected] bin]#./mysql-u Root MySQL

mysql> UPDATE user SET Password=password (' NewPassword '); Please change the newpassword to the password you set, other unchanged
mysql> FLUSH privileges;
Mysql> quit

[[Email protected] bin]# service MySQL start

Installing MySQL 5.7 under CentOS 6.5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.