Mysql5.6.36 script compilation and installation and initialization tutorial, mysql5.6.36 Initialization

Source: Internet
Author: User
Tags uncompress

Mysql5.6.36 script compilation and installation and initialization tutorial, mysql5.6.36 Initialization

Overview

This document describes how to automatically compile and install the script of mysql5.3.6 for centos7.3 and subsequent initialization operations.

The installation script install. py is as follows:

# Coding = UTF-8 #! /Usr/bin/pythonimport OS, commands # defines the variable install_dir = '/data/mysql' data _ dir ='/data/mysql/data' package _ dir = '/data/mysql' log _ dir = '/ data/mysql/logs' current _ dir = OS. getcwd () cmake = 'cmake-DCMAKE_INSTALL_PREFIX = % s-DMYSQL_UNIX_ADDR = % s/mysql. sock-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-DMYSQL_DATADIR = % s-Limit = 3306 '% (install_dir, install_dir, data_dir) # Install the dependency package OS. system ('Yum install gcc-c ++ gcc-g77 autoconf automake zlib * fiex * libxml * ncurses-devel libmcrypt * libtool-ltdl-devel * make cmake perl-y ') # Install function def install_mysql (): if OS. system ('groupadd mysql') = 0: print 'group mysql add success! 'Else: exit ('group mysql add failed! ') If OS. system ('useradd-r-g mysql-s/bin/false mysql') = 0: print 'user mysql add success! 'Else: exit ('user mysql add failed! ') If not OS. path. exists (install_dir): OS. system ('mkdir-p % s' % install_dir) if not OS. path. exists (data_dir): OS. system ('mkdir-p % s' % data_dir) if not OS. path. exists (package_dir): OS. system ('mkdir-p % s' % package_dir) if not OS. path. exists (log_dir): OS. system ('mkdir-p % s' % log_dir) if OS. system ('tar zxvf mysql-5.6.36.tar.gz ') = 0: print 'uncompress v success! 'Else: exit ('uncompress mysql-5.6.36.tar.gz failed! ') OS. chdir ('mysql-5.6.36 ') if OS. system (cmake) = 0: print 'compilation succeeded 'else: exit ('mysql compilation failed') if OS. system ('make & make install') = 0: print 'mysql compilation and installation succeeded. 'else: exit ('mysql compilation and installation failed') if OS. system ('chown-R mysql: mysql % s' % install_dir) = 0: print 'installation directory permission configuration successful 'else: exit () OS. system ('chown-R mysql: mysql % s' % data_dir) OS. system ('CD % s & touch mysql-error.log '% log_dir) OS. system ('chown-R mysql: mysql % s' % log_dir) OS. chdir (install_dir) if OS. system ('. /scripts/mysql_install_db -- user = mysql -- datadir = % s' % data_dir) = 0: print 'mysql initialization successful 'else: exit ('mysql initialization failed') OS. system ('cp support-files/mysql. server/etc/init. d/mysqld ') OS. system ('mv/etc/my. cnf/etc/my. cnf. bak') OS. chdir (current_dir) OS. system ('cp my. cnf/etc/my. cnf ') OS. system ('service mysqld start') OS. system ('chkconfig mysqld on ') install_mysql () if OS. path. exists ('/etc/profile'): OS. system ('cp/etc/profile. bak') if OS. system ('echo "PATH = % s/bin: % s/lib: $ PATH">/etc/profile '% (install_dir, install_dir) = 0: print 'Modified/etc/profile successfully' else: exit () if OS. system ('echo "export PATH">/etc/profile ') = 0: print' the/etc/profile file is modified successfully. 'else: exit ()

Configuration File my. cnf

[mysqld]basedir = /data/mysqldatadir = /data/mysql/datatmpdir = /data/mysqlsocket = /data/mysql/mysql.sockskip-external-lockingskip-name-resolvelower_case_table_names=1auto_increment_offset = 1 auto_increment_increment = 2 #server-id########## binlog ##########log_bin = /data/mysql/logs/mysql-binbinlog_format = rowbinlog_cache_size = 2Mexpire-logs-days = 7########## error log ##########log_error = /data/mysql/logs/mysql-error.log########## slow log ##########slow_query_log = 1slow_query_log_file = /data/mysql/logs/mysql-slow.loglong_query_time = 5########## per_thread_buffers ##########max_connections = 1024max_connect_errors = 1000key_buffer_size = 64Mmax_allowed_packet = 128Mtable_open_cache = 6144table_definition_cache = 4096sort_buffer_size = 512Kread_buffer_size = 512Kjoin_buffer_size = 512Ktmp_table_size = 64Mmax_heap_table_size = 64Mthread_cache_size = 64thread_concurrency = 32bulk_insert_buffer_size = 64M########innodb########innodb_buffer_pool_size = 45Ginnodb_log_file_size = 500Minnodb_log_buffer_size = 64Minnodb_flush_log_at_trx_commit = 2innodb_file_per_table = 1innodb_file_io_threads = 4innodb_flush_method = O_DIRECTinnodb_thread_concurrency = 0innodb_additional_mem_pool_size = 16M[mysqlhotcopy]interactive-timeout[mysqld_safe]open_files_limit = 65535

Usage:

1. Configure the yum source for the operating system
2. operating system version: centos7.3
3. Put the install. py my. cnf and mysql installation packages in a folder.

Mysql installation package: Link: https://pan.baidu.com/s/1pKHbFlh password: tx9b

Initialization

By default, mysql5.6.36 compiled and installed does not have a password. You can directly enter mysql in the command line to log on and execute the following SQL statement.

-- Initialize data use mysql; update user set password = PASSWORD ("Abcd123") where user = 'root'; grant all privileges on *. * to weihu @ "%" identified by "Abcd123"; delete from mysql. user where user = ''; flush privileges; -- CREATE a demo database create database 'Demo' default character set utf8 COLLATE utf8_general_ci; show databases;

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.