Install and uninstall Mysql in Mysql source code mode, and uninstall mysql in Mysql source code mode

Source: Internet
Author: User
Tags install perl

Install and uninstall Mysql in Mysql source code mode, and uninstall mysql in Mysql source code mode
1. Introduction to Basic Environment 1.1 Software Environment

Operating System: redhat linux 6.3

Mysql version: Mysql 5.6.24

1.2 disk directory Planning

Serial number

Directory

Purpose

1

/Opt/mysql/mysql-5.6.24

Mysql main program installation directory

2

/Data/mysql/mysql_5624/{data, tmp, logs}

Stores data files, temporary files, and log files. The value 5624 indicates version 5.6.24.

 

2. linux environment adjustment and optimization 2.1 disable NUMA

Edit the/etc/grub. conf file and add numa = offelevator = deadline

2.2 disable selinux

Edit the/etc/selinux/config file and add SELINUX = disabled at the end.

2.3 modify the unlimit Parameter

Edit the/etc/security/limits. conf file and add the following four lines:

Root soft nofile 65535

Root hard nofile 65535

 

Root soft nproc 7000

Root hard nproc 7000

2.4 disable iptables

# Service iptables stop

#/Etc/init. d/iptables stop

# Chkconfig iptables off

2.5 modify Environment Variables

# Vi. bash_profile

Add the following content:

Export PATH =/usr/local/mysql/bin:/opt/mysql/mysql-5.6.24/bin: $ HOME/bin: $ PATH

# Source. bash_profile

 

We recommend that you restart linux once at this step and verify that the parameters and other configurations take effect.

3. Install mysql3.1 to create directories for installation and storage of data files

# Mkdir-p/opt/mysql/mysql-5.6.24.

# Mkdir-p/data/mysql/mysql_5624/{data, tmp, logs}

3.2 Create Mysql users and user groups

# Groupadd mysql

# Useradd-g mysql-s/sbin/nologin-d/opt/mysql

3.3 install the DBD module package of mysql

DBD module package name: perl-DBD-MySQL-3.0007-2.el5.x86_64.rpm

# Yum install cmake * gcc * libaio-devel automake autoconf bzbison libtool ncurses

# Yum install perl-DBD-MySQL

 

For the configuration of yum, please refer to the author published in the blog oracle_linux_6_64 (bit) on the installation of oracle11gR2 database environment quick preparation artifact oracle-rdbms-server-11gR2-preinstall chapter 3rd: build a local yum server to use oracle-rdbms-server-11gR2-preinstall, blog site: http://blog.csdn.net/ljunjie82/article/details/37373595

 

3.4 download the source code installation package

:

Http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz

3.5 upload compressed files to the server

Upload the downloaded mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz source code installation file to the/opt/mysql/directory of the server (method omitted)

3.6 decompress the mysql installation package

# Tar-xzvf/opt/mysql/mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz-C/opt/mysql/mysql-5.6.24/

3.7 cut the decompressed file to the planned installation directory

# Cd/opt/mysql/mysql-5.6.24

# Mv mysql-5.6.24-linux-glibc2.5-x86_64 /*.

# Rm-rf mysql-5.6.24-linux-glibc2.5-x86_64

3.8 create ln soft link

The purpose of creating a soft link: To store multiple mysql versions on the server, you can use the soft link to flexibly point to the version you want to use, which is most useful during upgrade.

# Ln-s/opt/mysql/mysql-5.6.24/usr/local/mysql

3.9 change Directory Permissions

# Chown-R mysql: mysql/usr/local/mysql

# Chown-R mysql: mysql/data/mysql

# Chown-R mysql: mysql/opt/mysql

3.10 check whether the dependent lib library is secure

# Ldd/usr/local/mysql/bin/mysqld

 

4. Configure the my. cnf parameter and database initialization 4.1 configure the my. cnf Parameter

(1) backup/etc/my. cnf

# Mv/etc/my. cnf/etc/my. cnf_backup

(2) create a new/etc/my. cnf File

# Vi/etc/my. cnf

[Client]

Port = 3306

Socket =/tmp/mysql. sock

 

[Mysql]

Prompt = [master]>

# Pager = "less-I-n-S"

Tee =/data/mysql/mysql_5624/data/query. log

No-auto-rehash

 

[Mysqld_multi]

Mysqld =/usr/local/mysql/bin/mysqld_safe

Mysqladmin =/usr/local/mysql/bin/mysqladmin

Log =/opt/mysql/mysqld_multi.log

 

[Mysqld]

# Misc

Explicit_defaults_for_timestamp = ture

User = mysql

Basedir =/usr/local/mysql

Datadir =/data/mysql/mysql_5624/data

Port = 3306

Socket =/tmp/mysql. sock

Event_scheduler = 0

 

# Timeout

Interactive_timeout = 300

Wait_timeout = 300

 

# Character set

Character-set-server = utf8

 

Open_files_limit = 65535

Max_connections = 100

Max_connect_errorrs = 100000

Skip-name-resolve = 1

# Logs

Log-output = file

Slow_query_log = 1

Slow_query_log_file = slow. log

Log-error =/data/mysql/mysql_5624/data/error. log

Log_warnings = 2

Pid-file = mysql. pid

Long_query_time = 1

# Log-slow-admin-statements = 1

# Log-queries-not-using-indexes = 1

Log-slow-slave-statements = 1

 

# Binlog

Binlog_format = mixed

Servers-id = 2003306

Log-bin =/data/mysql/mysql_5624/logs/mybinlog

Binlog_cache_size = 4 M

Max_binlog_size = 1G

Max_binlog_cache_size = 2G

Sync_binlog = 0

Expire_logs_days = 10

 

# Relay log

Skip_slave_start = 1

Max_relay_log_size = 1G

Relay_log_purge = 1

Relay_log_recovery = 1

Log_slave_updates

# Slave-skip-errors = 1062

 

# Buffers & cache

Table_open_cache = 2048

Table_definition_cached = 2048

Table_open_cache = 2048

Max_heap_table_size = 96 M

Sort_buffer_size = 2 M

Join_buffer_size = 2 M

Thread _ cache_size = 256

Query_cache_size = 0

Query_cache_type = 0

Query_cache_limit = 256 K

Query_cache_min_res_unit = 512

Thread_stack = 192 K

Tmp_table_size = 96 M

Key_buffer_size = 8 M

Read_buffer_size = 2 M

Read_rnd_buffer_size = 16 M

Bulk_insert_buffer_size = 32 M

 

# Myisam

Myisam_sort_buffer_size = 128 M

Myisam_max_sort_file_size = 10G

Myisam_repair_threads = 1

 

# Innodb

Innodb_buffer_pool_size = 100 M

Innodb_buffer_pool_instances = 1

Innodb_data_file_path = ibdata1: 1G: autoextend

Innodb_flush_log_at_trx_commit = 1

Innodb_log_buffer_size = 64 M

Innodb_log_file_size = 256 M

Innodb_log_files_in_group = 3

Innodb_max_dirty_pages_pct = 50

Innodb_file_per_table = 1

Innodb_rollback_on_timeout

Innodb_status_file = 1

Innodb_io_capacity = 2000

Transaction_isolation = READ-COMMITTED

Innodb_flush_method = O_DIRECT

 

# Special configurations of an instance whose port is 3306

[Mysqld3306]

Port = 3306

# Specify the basedir and datadir versions of the Instance

Basedir =/usr/local/mysql

Datadir =/data/mysql/mysql_5624/data

Socket =/tmp/mysql_5624.sock

# Re-configuring these options will directly overwrite the above global settings, not the same as the global configuration.

Innodb_buffer_pool_size = 100 m

Transaction_isolation = REPEATABLE-READ

 

###### Related Backup parameters for multiple mysql versions #####

# [MysqldXXXX]

# Port = 3308

# Basedir =/usr/local/mysql

# Datadir =/data/mysql/mysql_XXXX/data

# Socket =/tmp/mysql_XXXX.sock

# Re-configuring these options will directly overwrite the above global settings, not the same as the global configuration.

# Innodb_buffer_pool_size = 100 m

# Innodb_flush_log_at_trx_commit = 2

# Sync_binlog = 0

 

4.2 initialize mysql

Note: The database initialization must be performed under the basedir directory.

# Cd/usr/local/mysql

#./Scripts/mysql_install_db -- user = mysql -- defaults-file =/etc/my. cnf

#./Scripts/mysql_install_db -- datadir =/data/mysql/mysql_5624/data -- defaults-file =/etc/my. cnf

5. Start and close mysql5.1 start mysql

(1) mysql

#/Etc/init. d/mysql start

Starting MySQL... SUCCESS!

(2) Verify that mysql is running

# Ps axu | grep mysqld

Root 3329 0.1 0.0 106272 1412 pts/0 S/bin/sh/usr/local/mysql/bin/mysqld_safe -- datadir =/data/mysql/mysql_5624/data -- pid- file =/data/mysql/mysql_5624/data/mysql. pid

Mysql 4267 3.6 29.6 1121464 565388 pts/0 Sl/usr/local/mysql/bin/mysqld -- basedir =/usr/local/mysql -- datadir =/data/mysql/mysql_5624 /data -- plugin-dir =/usr/local/mysql/lib/plugin -- user = mysql -- log-error =/data/mysql/mysql_5624/data/error. log -- open-files-limit = 65535 -- pid-file =/data/mysql/mysql_5624/data/mysql. pid -- socket =/tmp/mysql. sock -- Ports = 3306

(3) Verify that the configured port 3306 is listened on

# Netstat-NCLP | grep "3306"

Tcp 0 0: 3306: * LISTEN 4267/mysqld

 

5.2 close mysql

# Mysqladmin-uroot shutdown

6. Fully uninstall Mysql

(1) query the installed mysql package

# Rpm-qa | grep mysql

(2) completely uninstall using yum

# Yum remove mysql-server mysql-libsmysql-connector

(3) manually delete the Created directory and my. cnf File

# Rm-rf/opt/mysql

# Rm-rf/data/mysql

# Rm/etc/my. cnf

(4) manually delete the created soft link

# Cd/usr/local

# Rm mysql

 

 

Author: LI Junjie (Network Name: Step-by-Step), engaged in "system architecture, operating system, storage device, database, middleware, application" six levels of systematic performance optimization work

Join the system performance optimization professional group to discuss performance optimization technologies. GROUP: 258187244

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