Install mysql in linux (one-click installation of shell) and mysqlshell
1. Related Files (install_mysql.sh, my. cnf, and mysqld are at the bottom of the text)
2. Upload the above files to a directory on the linux Server
3. Grant the execution permission to install_mysql.sh.
# Chmod + x instll_mysql.sj
4. Run install_mysql.sh.
#./Install_mysql.sh
5. Verify
6. install_mysql.sh content
#! /Bin/sh
# Retrieving the current path
Mypath = $ (cd $ (dirname $0)/; pwd)
# Installation target path
Dirpath =/usr/local/src/mysql
Mkdir $ {dirpath}
# Related software installation
Cd/
Yum-y install gcc
Yum-y intall gcc-c ++
Yum-y install ncurses-devel
# Installing cnake
Cd $ {dirpath}
Wget -- no-check-certificate http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
Tar zxvf cmake-2.8.8.tar.gz
Cd ${dirpath}/cmake-2.8.8
./Configure
Make
Make install
# Add a mysql user group
Groupadd mysql
Useradd-g mysql-s/bin/false
# Mysql Data storage directory
Mkdir-p/data/mysql
Chown-R mysql: mysql/data/mysql
# Mysql installation directory
Mkdir-p/usr/local/mysql
# Install mysql
Tar zxvf $ {mypath}/mysql-5.5.59.tar.gz-C $ {dirpath}
Cd ${dirpath}/mysql-5.5.59
Cmake.-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/data/mysql-DSYSCONFDIR =/etc
Make
Make install
# Configure my. cnf (here I will directly replace my. cnf with a local configuration)
Cp/etc/my. cnf/etc/my. cnf_bak _ 'date + % Y % m % d'
/Bin/cp-rf $ {mypath}/my. cnf/etc/my. cnf
# Mysql Production System Database
Cd/usr/local/mysql
./Scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/data/mysql
# Configure mysqld (here I use the locally prepared mysqld for direct replication)
/Bin/cp-rf $ {mypath}/mysqld/etc/rc. d/init. d/mysqld
Chmod 755/etc/init. d/mysqld
# Start mysql at startup (optional)
Chkconfig mysqld on
# Start mysql
Service mysqld start
# Configure Environment Variables
Profile =/etc/profile
Path = "export PATH = $ PATH:/usr/local/mysql/bin"
Echo $ path> $ profile
Source/etc/profile
./Etc/profile
# Establish a soft connection
Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
Ln-s/usr/local/mysql/include/mysql/usr/include/mysql
Ln-s/usr/local/mysql/bin/mysql/usr/bin
# Create a mysql root User Password (only available for the first installation)
/Usr/local/mysql/bin/mysqladmin-u root password "sa"
# Restart mysql
Service mysqld restart
7. my. cnf content (add a line at the bottom)
Datadir =/data/mysql
8. mysqld content (modify 2 rows)
Basedir =/usr/local/mysql
Datadir =/data/mysql