Get the App
SLTechnology News&Howtos  ›  Database  › 

MySQL5.6 one-click compilation and installation script sharing

Shulou Source: shulou.com Published: 2022-05-31 19:20:46 10月03日 Update

This article focuses on "MySQL5.6 one-click compilation and installation script sharing", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "MySQL5.6 one-click compilation and installation script sharing"!

#! / bin/bash

# Notes: install mysql5.6 on centos

#

Mysql_install_dir=/usr/local/mysql

Mysql_data_dir=/data/mysql

Mysql_6_version=5.6.26

Dbrootpwd=root

Mem= `free-m | awk'/ Mem:/ {print $2}'`

Swap= `free-m | awk'/ Swap:/ {print $2}'`

Install_MySQL-5-6 ()

{

Yum-y install make gcc-c++ cmake bison-devel ncurses-devel

Wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-${mysql_6_version}.tar.gz

Id-u mysql > / dev/null 2 > & 1

[$?-ne 0] & & useradd-M-s / sbin/nologin mysql

Mkdir-p $mysql_data_dir;chown mysql.mysql-R $mysql_data_dir

Tar zxf mysql-$ {mysql_6_version} .tar.gz

Cd mysql-$mysql_6_version

Make clean

[!-d "$mysql_install_dir"] & & mkdir-p $mysql_install_dir

Cmake. -DCMAKE_INSTALL_PREFIX=$mysql_install_dir\

-DMYSQL_DATADIR=$mysql_data_dir\

-DSYSCONFDIR=/etc\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_PARTITION_STORAGE_ENGINE=1\

-DWITH_FEDERATED_STORAGE_ENGINE=1\

-DWITH_BLACKHOLE_STORAGE_ENGINE=1\

-DWITH_MYISAM_STORAGE_ENGINE=1\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DENABLED_LOCAL_INFILE=1\

-DENABLE_DTRACE=0\

-DEXTRA_CHARSETS=all\

-DDEFAULT_CHARSET=utf8mb4\

-DDEFAULT_COLLATION=utf8mb4_general_ci\

-DWITH_EMBEDDED_SERVER=1\

Make-j `grep processor / proc/cpuinfo | wc-l`

Make install

If [- d "$mysql_install_dir/support-files"]; then

Echo "${CSUCCESS} MySQL install successfully! ${CEND}"

Cd..

Rm-rf mysql-$mysql_6_version

Else

Rm-rf $mysql_install_dir

Echo "${CFAILURE} MySQL install failed, Please contact the author! ${CEND}"

Kill-9 $$

Fi

/ bin/cp $mysql_install_dir/support-files/mysql.server / etc/init.d/mysqld

Chmod + x / etc/init.d/mysqld

Chkconfig mysqld on

Cd..

# my.cf

[- d "/ etc/mysql"] & & / bin/mv / etc/mysql {, _ bk}

Cat > / etc/my.cnf > / etc/profile

[- n "``grep ^ 'export PATH=' / etc/ profile`"-a-z "`grep $mysql_install_dir/ etc/ profile`"] & & sed-I "s@ ^ export PATH=\ (. *\) @ export PATH=$mysql_install_dir/bin:\ 1@" / etc/profile

. / etc/profile

$mysql_install_dir/bin/mysql-e "grant all privileges on *. * to root@'127.0.0.1' identified by\" $dbrootpwd\ "with grant option;"

$mysql_install_dir/bin/mysql-e "grant all privileges on *. * to root@'localhost' identified by\" $dbrootpwd\ "with grant option;"

$mysql_install_dir/bin/mysql-uroot-p$dbrootpwd-e "delete from mysql.user where Password='';"

$mysql_install_dir/bin/mysql-uroot-p$dbrootpwd-e "delete from mysql.db where User='';"

$mysql_install_dir/bin/mysql-uroot-p$dbrootpwd-e "delete from mysql.proxies_priv where hostworthy localhostworthy;"

$mysql_install_dir/bin/mysql-uroot-p$dbrootpwd-e "drop database test;"

$mysql_install_dir/bin/mysql-uroot-p$dbrootpwd-e "reset master;"

Rm-rf / etc/ld.so.conf.d/ {mysql,mariadb,percona} * .conf

Echo "$mysql_install_dir/lib" > mysql.conf

/ sbin/ldconfig

Service mysqld stop

}

Install_MySQL-5-6

At this point, I believe you have a deeper understanding of "MySQL5.6 one-click compilation and installation script sharing". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Scripts one-click compilation content learning practical deeper interest practicality practical easy to operate methods more friends websites channels queries Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi NVidia Docker OPPO Reno Huawei