Recently writing a MySQL shell installation script
It means that all the paths inside are absolute paths.
Here's a summary of some of the problems that are encountered with the installation and the installation process
This is a self-bringing installation process.
shell> Groupadd mysqlshell> useradd-r-g MySQL mysqlshell> cd/usr/localshell> tar zxvf/path/to/mysql-versio n-os.tar.gzshell> ln-s full-path-to-mysql-version-os mysqlshell> cd mysqlshell> chown-r mysql .shell> chgrp -R MySQL .shell> scripts/mysql_install_db--user=mysqlshell> chown-r root .shell> chown-r MySQL datashell> Bin/mysqld_safe--user=mysql Next command is optionalshell> CP support-files/mysql.server/etc/init.d/ Mysql.server
Before installing first check that there is no MySQL process, if there is anything we also install
' {print $} ' `; if 3 ]; Then " MySQL is installed"
Exit
Fi
Then download (can be downloaded from the official website, but the personal feeling is too slow, so built a simple FTP server, of course, can also be uploaded locally, here I will not elaborate)
# download MySQL packageyum install Libaio #MySQL的一个依赖包/usr/bin/yum Install awk wget- Ymysqldownloadurl=ftp://..... /pub/mysql/mysql-5.6.25-linux-glibc2.5-x86_64.tar.gz; CD/tmp; /BIN/RM-RF mysql*. tar.gz/usr/bin/wget $mysqlDownloadURL;
All right, we've already downloaded it.
Let's get down to the chase.
Unzip, create a soft connection
Packagename= '/bin/ls | /bin/grep mysql*tar.gz '; # unpakcage MySQL/bin/tar zxvf $packageName-C/usr/Localmysqlallnamedir ' {print $9} ' '/bin/ln-s $mysqlAllNameDir/usr/local/mysql
Add Users and user groups (judge if you add them without adding them)
' : ' ' {print $} ' | /USR/BIN/WC-l 'if1 ];then /usr/sbin/groupadd mysql /usr/ sbin/useradd-d/usr/local/mysql-s/sbin/nologin-g MySQL mysql" successfully added " fi
Check/etc If there are my.cnf files, some will kill, or backup
/bin/MV /etc/my.cnf/etc/my.cnf.bak
Initialize the following
/usr/local/mysql/scripts/mysql_install_db--datadir=/usr/local/mysql/data--user=mysql--basedir=/usr/local/mysql
Description of a point!!! Modify permissions must be initialized after initialization, otherwise the data directory after initialization is not necessarily attached permissions
/bin/chown-r Root.mysql/usr/local/mysql
/bin/chown -R mysql.mysql/usr/local/mysql/data/
Now you can write a configuration file yourself under/etc
/ETC/MY.CNF (It is also stated here that the MySQL configuration file has the parameter substitution principle)
This is the order.
/ETC/MY.CNF/ETC/MYSQL/MY.CNF/USR/LOCAL/MYSQL/ETC/MY.CNF ~/.my.cnf
[Client]socket=/usr/local/mysql/mysql-files/Mysql.sock[mysqld]explicit_defaults_for_timestamp=trueDataDir=/usr/local/mysql/Datasocket=/usr/local/mysql/mysql-files/Mysql.sockuser=mysql# Disabling Symbolic-links are recommended to prevent assorted security riskssymbolic-links=0# Logslow_query_log=1Slow_query_log_file=/usr/local/mysql/mysql-files/mysql-Slow.loglong_query_time=2# General Log#general_log=1#general_log_file=/usr/local/mysql/mysql-files/mysql-general.log# BINARY logserver_id=101Log_bin=/usr/local/mysql/mysql-files/mysql-Bin.logbinlog_format=Rowsync_binlog=1expire_logs_days=7# ERROR Loglog_error=/usr/local/mysql/mysql-files/mysql.err# Othercharacter_set_server=utf8mb4transaction-isolation = read-committedmax_connections= +Log-queries-not-using-indexeslog_throttle_queries_not_using_indexes=Ten# Innodbinnodb_strict_mode=1Innodb_file_format=Barracudainnodb_file_format_max=barracudainnodb_read_io_threads=4innodb_write_io_threads=8#8~ Ainnodb_io_capacity= +# HDD: -~ -Ssds:10000+innodb_adaptive_flushing=1# SSD:0Innodb_flush_log_at_trx_commit=1innodb_max_dirty_pages_pct= theInnodb_buffer_pool_dump_at_shutdown=1Innodb_buffer_pool_load_at_startup=1innodb_flush_neighbors=1# SSD:0innodb_log_file_size=1024m # ssd:4g~8g hdd:1g~2ginnodb_purge_threads=1# SSD:4Innodb_lock_wait_timeout=3Innodb_print_all_deadlocks=1PID-file=/usr/local/mysql/data/mysqld/Mysqld.pid[mysqld_safe]log-error=/var/log/Mysqld.logpid-file=/usr/local/mysql/data/mysqld/mysqld.pid
The following starts in Mysql_safe mode
/usr/local/mysql/bin/mysqld_safe &
Okay, now, start mysqld.
/usr/local/mysql/bin/mysqld restart
[Email protected] mysql]#./bin/Mysqlwelcome to the MySQL Monitor. Commands End With; or \g.your MySQL connectionIDIs2Server Version:5.6. --log MySQL Community Server (GPL) Copyright (c) -, -, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or Itsaffiliates. Other names trademarks of their respectiveowners. Type'Help ;'Or'\h' forHelp. Type'\c'ToClearThe current input statement.mysql>show databases;+--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Performance_schema | | Test |+--------------------+4RowsinchSet (0.00sec) MySQL>
Explain the points:
1. Remove reinstall when you must see whether the process of mysqld all killed (Ps-ef|grep mysqld), if you have to use the "kill-9 process number" to kill, it will seriously affect the next installation
2. It may be the second time that MySQL is installed on the machine, with residual data affecting the start of the service. Go to MySQL Data directory/data Look, if there is mysql-bin.index, delete
Other instructions I have explained in the previous installation process
Here is the basic procedure for installing scripts
#!/bin/bash# MySQLInstallScript, the home directory is/usr/local/mysql-version and the soft link is/usr/local/MySQLYum InstallLibaio/usr/bin/Yum Install awk wget-Yconfig= '/bin/pwd' Mysqlprocessnum= '/bin/PSAux | /bin/grepMySQL | /usr/bin/WC-L | /bin/awk '{print $}'`;if[$mysqlProcessNum-GT3]; Then Echo "MySQL is already installed"fi# download MySQL packagemysqldownloadurl=FTP://222.26.224.236/pub/mysql/mysql-5.6.25-linux-glibc2.5-x86_64.tar.gz;CD/tmp;/bin/RM-RF mysql*.Tar. GZ/usr/bin/wget$mysqlDownloadURL;p ackagename= '/bin/ls| /bin/grepmysql*.Tar. gz '; # unpakcage MySQL/bin/TarZXVF $packageName-C/usr/Localmysqlallnamedir= '/bin/ls-l/usr/local |grepMySQL | /bin/awk '{print $9}'`/bin/LN-S $mysqlAllNameDir/usr/local/Mysqlusernum= '/bin/Cat/etc/passwd| /bin/grepMySQL | /bin/awk-F':' '{print $}'| /usr/bin/WC-l 'if[$userNum-lt1]; Then/usr/sbin/Groupadd MySQL/usr/sbin/useradd-d/usr/local/mysql-s/sbin/nologin-g MySQL MySQLEcho "successfully added"fi
#/bin/mv/etc/my.cnf/etc/My.cnf.bak
/usr/local/mysql/scripts/mysql_install_db--datadir=/usr/local/mysql/data--user=mysql--basedir=/usr/local/ MySQL/bin/chown -R root.mysql/usr/local/MySQL/bin/chown -R mysql.mysql/usr/local/ mysql/data/
#我的配置文件放到root目录下面了
/bin/CP $config/my.cnf/etc/
/usr/local/mysql/bin/mysqld_safe &
#/bin/chown -R mysql.mysql/usr/local/mysql/data/#/bin/cp $config/my.cnf/etc/ # CP /usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld#chmod755 /etc/init.d/mysqld
Wish success
MySQL5.6 binary installation of Linux installation (i)