Install and optimize Mysql in Linux

Source: Internet
Author: User

Install and optimize Mysql in Linux
System Environment: CentOS 6.5
Mysql version: mysql-5.6.19.tar.gz
Software upload path:/doiido/soft

1. Install Mysql
1: Firewall opens the corresponding port
#/Sbin/iptables-I INPUT-p tcp -- dport 3306-j ACCEPT
#/Etc/rc. d/init. d/iptables save

2: Install related dependency packages
# Yum-y install gcc-c ++ ncurses-devel openssl-devel cmake perl lsof bison

3: delete the mysql
# Rpm-qa | grep mysql
# Rpm-e -- allmatches -- nodeps mysql-libs-5.1.71-1.el6.x86_64

4. Create related directories
# Mkdir/doiido/soft
# Mkdir-p/doiido/mysql/data/

5. Create a mysql user
#/Usr/sbin/groupadd mysql
#/Usr/sbin/useradd-s/sbin/nologin-M-g mysql
# Chown-R mysql: mysql/doiido/mysql/

6. Install mysql
# Cd/doiido/soft
# Tar-zxvf mysql-5.6.19.tar.gz
# Cd mysql-5.6.19
# Cmake-DCMAKE_INSTALL_PREFIX =/doiido/server/mysql-DMYSQL_DATADIR =/doiido/mysql/data-encoding = 1-runtime = 1-runtime = 1-DSYSCONFDIR =/etc/-DWITH_SSL = yes-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-DWITH_READLINE = on
# Make & make install

7. Modify related directory permissions and create a soft connection
# Chmod + w/doiido/server/mysql
# Chown-R mysql: mysql/doiido/server/mysql/
# Ln-s/doiido/server/mysql/lib */usr/lib/
# Ln-s/doiido/server/mysql/bin/mysql/usr/bin

8. modify the configuration file.
# Cp/doiido/server/mysql/support-files/my-default.cnf/etc/my. cnf
# Vi/etc/my. cnf
Character-set-server = utf8
Default-storage-engine = MyISAM
Basedir =/doiido/server/mysql
Datadir =/doiido/mysql/data
Log-error =/doiido/mysql/mysql_error.log
Pid-file =/doiido/mysql. pid
Max_allowed_packet = 32 M
Explicit_defaults_for_timestamp = true

9. Install the mysql database.
#/Doiido/server/mysql/scripts/mysql_install_db -- basedir =/doiido/server/mysql -- datadir =/doiido/mysql/data -- user = mysql

10: Set mysql to automatically start the service
# Cp/doiido/server/mysql/support-files/mysql. server/etc/init. d/mysqld
# Chkconfig -- add mysqld
# Chkconfig -- level 345 mysqld on

11. Modify the mysqld file and start mysql
# Vi/etc/init. d/mysqld
# Modify the following two items in the mysqld File
Basedir =/doiido/server/mysql
Datadir =/doiido/mysql/data

# Service mysqld start

Ii. mysql Optimization
Software Version
Libunwind: libunwind-1.1.tar.gz
Google-perftools: gperftools-2.2.tar.gz

1: Install libunwind (based on 64-bit)
# Cd/doiido/soft
# Tar zxvf libunwind-1.1.tar.gz
# Cd libunwind-1.1
# CFLAGS =-fPIC./configure
# Make CFLAGS =-fPIC
# Make CFLAGS =-fPIC install

2: Install google-perftools:
# Cd/doiido/soft
# Tar zxvf gperftools-2.2.tar.gz
# Cd gperftools-2.2/
# Make & make install
# Echo "/usr/local/lib">/etc/ld. so. conf. d/usr_local_lib.conf

3: Modify the MySQL STARTUP script (depending on the MySQL installation location ):
# Vi/doiido/server/mysql/bin/mysqld_safe
Add the following to # executing mysqld_safe:

Export LD_PRELOAD =/usr/local/lib/libtcmalloc. so

# Service mysqld restart

4: Check whether tcmalloc is effective:
#/Usr/sbin/lsof-n | grep tcmalloc
If the following information is found, tcmalloc has taken effect:

Mysqld 11227 mysql mem REG 2171746 18287/usr/local/lib/libtcmalloc. so.4.1.2

Related Article

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: 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.