[root@lamp ~]# cat /server/scripts/mysql-5.6.43_install.sh
#!/bin/bash
#卸载系统自带的Mysql
/bin/rpm -e $(/bin/rpm -qa | grep mysql|xargs) --nodeps
/bin/rm -f /etc/my.cnf #安装编译代码需要的软件包
/usr/bin/yum -y install make gcc-c++ cmake bison-devel ncurses-devel #创建mysql用户及其用户组
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql -M -s /sbin/nologin #编译安装mysql-5.6.43
cd /usr/local/src
wget -c -P ./ http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/mysql-5.6.43.tar.gz
/bin/tar -zxvf mysql-5.6.43.tar.gz
cd mysql-5.6.43/
/usr/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make && make install #创建并修改/usr/local/mysql软件目录和mysql数据存放目录/data/mysql/data权限
mkdir -p /data/mysql/data /usr/local/mysql
/bin/chown -R mysql:mysql /usr/local/mysql
/bin/chown -R mysql:mysql /data/mysql/data #执行初始化配置脚本,创建系统自带的数据库和表
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/data --user=mysql #配置mysql配置文件/usr/local/mysql/my.cnf
cat > /usr/local/mysql/my.cnf << EOF
[client]
port = 3306
socket = /usr/local/mysql/var/mysql.sock [mysqld]
port = 3306
socket = /usr/local/mysql/var/mysql.sock basedir = /usr/local/mysql/
datadir = /data/mysql/data
pid-file = /data/mysql/data/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1
sync_binlog=1
log_bin = mysql-bin skip-name-resolve
#skip-networking
back_log = 600 max_connections = 3000
max_connect_errors = 3000
##open_files_limit = 65535
table_open_cache = 512
max_allowed_packet = 16M
binlog_cache_size = 16M
max_heap_table_size = 16M
tmp_table_size = 256M read_buffer_size = 1024M
read_rnd_buffer_size = 1024M
sort_buffer_size = 1024M
join_buffer_size = 1024M
key_buffer_size = 8192M thread_cache_size = 8 query_cache_size = 512M
query_cache_limit = 1024M ft_min_word_len = 4 binlog_format = mixed
expire_logs_days = 30 log_error = /data/mysql/data/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/data/mysql-slow.log performance_schema = 0
explicit_defaults_for_timestamp ##lower_case_table_names = 1 skip-external-locking default_storage_engine = InnoDB
##default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 1024M
innodb_write_io_threads = 1000
innodb_read_io_threads = 1000
innodb_thread_concurrency = 8
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 4M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120 bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1 interactive_timeout = 28800
wait_timeout = 28800 [mysqldump]
quick
max_allowed_packet = 16M [myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
port = 3306
EOF #启动mysql服务,添加环境变量
cd /usr/local/mysql
/bin/mkdir var
/bin/chown -R mysql.mysql var
cp support-files/mysql.server /etc/init.d/mysql
/sbin/chkconfig mysql on
service mysql start
echo "export PATH=/usr/local/mysql/bin:$PATH" >>/etc/profile && source /etc/profile
#设置mysql登陆密码,初始密码为123456
/bin/mkdir -p /var/lib/mysql
ln -s /usr/local/mysql/var/mysql.sock /var/lib/mysql/mysql.sock
mysql -e "SET PASSWORD = PASSWORD('123456');"
mysql -p123456 -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;"
mysql -p123456 -e "FLUSH PRIVILEGES;"

参考博客:http://www.cnblogs.com/kevingrace/p/6109679.html

一键安装MySQL5.6.43脚本的更多相关文章

  1. shell脚本一键安装mysql5.7.x

    使用脚本一键安装mysql5.7.x,初始化数据库.启动数据库---- mysql版本号:源代码mysql5.7.10 linux版本号:centos6.5 x86_64 #!/bin/bash GR ...

  2. shell脚本一键安装mysql5.7.x(免安装版)

    使用脚本一键安装mysql5.7.x,初始化数据库,启动数据库---- mysql版本:源码mysql5.7.10 linux版本:centos6.5 x86_64 #!/bin/bash GROUP ...

  3. centos7安装mysql-5.6.43二进制包

    卸载老版本的MySQL.查找并删除mysql有关的文件 # find / -name mysql # rm -rf /usr/lib64/mysql /usr/share/mysql [root@lo ...

  4. 一键安装apache-2.4.38脚本

    [root@lamp scripts]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) [root@lamp scripts ...

  5. 一键安装php5.6.40脚本(LAMP环境)

    #!/bin/bash #安装依赖软件 yum -y install libxml2-devel curl-devel libjpeg libjpeg-devel libpng libpng-deve ...

  6. CentOS6.x生产环境下一键安装mono+jexus的脚本,自启动,带服务,版本号自控

    转自: http://linuxdot.net/bbsfile-3784 1.支持哪些个平台?答:暂时仅支持CentOS6.x平台,7.x未测试,欢迎测试并到群里反馈给我(昵称:无聊人士) 2.一键安 ...

  7. linux下一键安装 powershell,的bash脚本

    说明 目前,linux下的powershell约等于pash.希望大家专注mono,关注pash. 一键安装脚本包括for centos6,centos7,ubuntu 14.04  ubuntu 1 ...

  8. CentOS7编译安装mysql-5.6.43

    Step 1:安装编译需要的软件和工具 [root@node-1 ~]# yum install gcc gcc-c++ cmake ncurses-devel bison Step 2:创建mysq ...

  9. 【shell 每日一练7】一键安装mysql5.7,以及密码及策略修改

    一.一键安装Mysql脚本 [root@uat01 ~]# cat InstallMysql01.sh #!/bin/bash #-- #旅行者-Travel #.安装wget yum -y inst ...

随机推荐

  1. ST表竞赛模板

    void RMQ_init(){//ST表的创建模板 ;i<n;i++) d[i][]=mo[i]; ;(<<j)<=n;j++) ;i+(<<j)-<n;i ...

  2. Alibaba Nacos 服务发现组件集群部署

    前面学习了单机模式下的启动,生产环境中部署nacos肯定是使用集群模式cluster保证高可用. 官方文档的集群部署推荐使用VIP+域名模式,把所有服务列表放到一个vip下面,然后挂到一个域名下面. ...

  3. log4j的xml配置

    主要记录下方便下次查找 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:conf ...

  4. C++ 引用分析

    引用 左值引用,建立既存对象的别名 右值引用,可用于为临时对象延长生命周期 转发引用,保持函数实参的类别 悬置引用,对象生命周期已经结束的引用,访问改引用为未定义行为 值类别,左值,纯右值,亡值 st ...

  5. 史上最详细的二叉树、B树,看不懂怨我

    今天我们要说的红黑树就是就是一棵非严格均衡的二叉树,均衡二叉树又是在二叉搜索树的基础上增加了自动维持平衡的性质,插入.搜索.删除的效率都比较高.红黑树也是实现 TreeMap 存储结构的基石. 1.二 ...

  6. jQuery-01-jQuery选择器及元素操作

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. BERT模型总结

    BERT模型总结 前言 ​ BERT是在Google论文<BERT: Pre-training of Deep Bidirectional Transformers for Language U ...

  8. 动态规划-Dynamic Programming(DP)

    动态规划 动态规划方法心得 ​ 动态规划是一般的面试.笔试中的高频算法题,熟练掌握必要的.动态规划的中心思想是在解决当前问题时,可以由之前已经计算所得的结果并结合现在的限制条件递推出结果.由于此前的计 ...

  9. Wireshark入门与进阶系列五之常见捕获过滤器

    0x00 前言 我们都知道,wireshark可以实现本地抓包,同时Wireshark也支持remote packet capture protocol(rpcapd)协议远程抓包,只要在远程主机上安 ...

  10. Typora常用快捷键

    目录 无序列表:输入-之后输入空格 有序列表:输入数字+"."之后输入空格 任务列表:-[空格]空格 文字 标题:ctrl+数字 表格:ctrl+t 生成目录:按回车 选中一整行: ...