Install and completely uninstall Mysql using Mysql source code

Source: Internet
Author: User

Install and completely uninstall Mysql using Mysql source code
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

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. logno-auto-rehash [mysqld_multi] mysqld =/usr/local/mysql/bin/mysqld_safemysqladmin =/usr/local/mysql/bin/mysqladminlog =/opt/mysql/mysqld_multi.log [mysqld] # miscexplicit_defaults_for_timestamp = tureuser = mysqlbasedir =/usr/local/mysqldatadir =/data/mysql/mysql_5624/dataport = 3306 socket =/tmp/mysql. sockevent_schedout = 0 # timeoutinteractive_timeout = 300wait_timeout = 300 # character setcharacter-set-server = bytes = 65535max_connections = bytes = 1 # logslog-output = bytes = slow. loglog-error =/data/mysql/mysql_5624/data/error. loglog_warnings = 2pid-file = mysql. pidlong_query_time = 1 # log-slow-admin-statements = 1 # log-queries-not-using-indexes = shards = 1 # binlogbinlog_format = mixedserver-id = 2003306log-bin =/data/mysql /mysql_5624/logs = 2Gsync_binlog = logs = 10 # relay logskip_slave_start = logs = 1relay_log_recovery = logs # slave-skip-errors = 1032,1053, 1062 # buffers & cachetable_open_cache = bytes = 2048table_open_cache = bytes = 0query_cache_type = bytes = 512thread_stack = 192Ktmp_table_size = bytes = 32 M # outputs = 128Mmyisam_max_sort_file_size = 10Gmyisam_repair_threads = 1 # innodbinnodb_buffer_pool_size = bytes = 1innodb_data_file_path = ibdata1: 1G: protocol = protocol = 50innodb_file_per_table = protocol = 1innodb_io_capacity = 2000transaction_isolation = READ-COMMITTEDinnodb_flush_method = O_DIRECT # instance special configuration with port 3306 [mysqld3306] port = 3306 # specify the corresponding instance basedir and datadirbasedir =/usr/local/mysqldatadir =/data/mysql/mysql_5624/datasocket =/tmp/mysql_5624.sock # reconfigure these options, unlike global configuration, will Directly overwrite the above global settings innodb_buffer_pool_size = 100mtransaction_isolation = REPEATABLE-READ ##### the following multiple versions of mysql related standby parameters ###### [mysqldXXXX] # port = 3308 # basedir =/usr/local/mysql # datadir =/data/mysql/mysql_XXXX/data # socket =/tmp/mysql_XXXX.sock # reconfigure these options, unlike the global configuration, the above global settings # 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 08:27 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql/mysql_5624/data --pid-file=/data/mysql/mysql_5624/data/mysql.pidmysql 4267 3.6 29.6 1121464 565388 pts/0 Sl 08:27 0:01 /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 --port=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

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.