#红色部分根据自己的需求来定义
#!/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 #编译安装mysql5.
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql -M -s /sbin/nologin
#转到/usr/local/src下
cd /usr/local/src #或是直接把tar包放在该目录下
#wget -c http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/mysql-5.6.36.tar.gz(此处填写正确的链接)
/bin/tar -zxvf mysql-5.6.31.tar.gz
cd mysql-5.6./
/usr/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DMYSQL_TCP_PORT= -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE= -DWITH_MYISAM_STORAGE_ENGINE= -DWITH_PARTITION_STORAGE_ENGINE= -DWITH_FEDERATED_STORAGE_ENGINE= -DWITH_BLACKHOLE_STORAGE_ENGINE= -DENABLED_LOCAL_INFILE= -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci
make && make install #修改/usr/local/mysql权限
mkdir -p /usr/local/mysql/data
/bin/chown -R mysql:mysql /usr/local/mysql
/bin/chown -R mysql:mysql /usr/local/mysql/data #执行初始化配置脚本,创建系统自带的数据库和表
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql #配置my.cnf
cat > /usr/local/mysql/my.cnf << EOF
[client]
port =
socket = /usr/local/mysql/mysql.sock [mysqld]
port =
socket = /usr/local/mysql/mysql.sock basedir = /usr/local/mysql/
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id =
sync_binlog=
log_bin = mysql-bin skip-name-resolve
#skip-networking
back_log = max_connections =
max_connect_errors =
##open_files_limit =
table_open_cache =
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 = query_cache_size = 512M
query_cache_limit = 1024M ft_min_word_len = binlog_format = mixed
expire_logs_days = log_error = /usr/local/mysql/data/mysql-error.log
slow_query_log =
long_query_time =
slow_query_log_file = /usr/local/mysql/data/mysql-slow.log performance_schema =
explicit_defaults_for_timestamp ##lower_case_table_names = skip-external-locking default_storage_engine = InnoDB
##default-storage-engine = MyISAM
innodb_file_per_table =
innodb_open_files =
innodb_buffer_pool_size = 1024M
innodb_write_io_threads =
innodb_read_io_threads =
innodb_thread_concurrency =
innodb_purge_threads =
innodb_flush_log_at_trx_commit =
innodb_log_buffer_size = 4M
innodb_log_file_size = 32M
innodb_log_files_in_group =
innodb_max_dirty_pages_pct =
innodb_lock_wait_timeout = bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = interactive_timeout =
wait_timeout = [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 =
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=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile #设置mysql登陆密码,初始密码为123456
/bin/mkdir -p /var/lib/mysql
ln -s /usr/local/mysql/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;"

MySQL源码安装一键脚本的更多相关文章

  1. Mysql源码安装shell脚本

    #!/bin/bash#date:2019/1/20#by author zhangjia#install mysql#shell_name:mysql_auto_install.sh######## ...

  2. maridb\mysql 源码安装,以10.1.26版本为例

    mysql 源码安装(mariadb 10.1.26) 1.环境部署 1 安装cmake 源码安装三部曲或者yum install cmake2安装依赖包yum install -y ncurses- ...

  3. mysql源码安装(5.1)

    下载mysql源码包并解压.wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.73.tar.gztar -zxvf mysql-5 ...

  4. CentOS 7运维管理笔记(10)----MySQL源码安装

    MySQL可以支持多种平台,如Windows,UNIX,FreeBSD或其他Linux系统.本篇随笔记录在CentOS 7 上使用源码安装MySQL的过程. 1.下载源码 选择使用北理工的镜像文件: ...

  5. Linux MySQL源码安装缺少ncurses-devel包

    在Red Hat Enterprise Linux Server release 5.7 上用源码安装MySQL-5.6.23时,遇到了" remove CMakeCache.txt and ...

  6. Linux(CentOS或RadHat)下MySQL源码安装

    安装环境: CentOS6.3 64位 软件: Mysql-5.6 所需包: gcc/g++ :MySQL 5.6开始,需要使用g++进行编译.cmake  :MySQL 5.5开始,使用cmake进 ...

  7. mysql源码安装(包括5.5和5.7)

    1.mysql5.5源码安装 yum install -y cmake ncurses-devel ncurses cd /usr/src wget -c https://cdn.mysql.com/ ...

  8. MySQL源码安装(centos)

    1.去MySQL官网下载源码包 地址:http://dev.mysql.com/downloads/mysql/ 下载完后需要检查文件的MD5,以确认是否从官网下载的原版本(以防被人篡改过该软件) 使 ...

  9. zabbix,php,nginx,mysql源码安装 神仙操作

    →软件包 mkdir /soft/ cd /soft ♦下载以下软件包 nginx-1.14.2.tar.gz wget http://nginx.org/download/nginx-1.14.2. ...

随机推荐

  1. tarjan算法(求强连通子块,缩点)

    tarjan算法求图中的强连通子图的个数. #include<iostream> #include<stack> #include<queue> #include& ...

  2. 由JDBC而来的对Class.forName()用法发散

    昨日在帮一个学习java的小伙子指导JDBC链接数据库时,在对数据库驱动进行加载时,用到Class.forName(),一直都是照葫芦画瓢,对这种写法一直不是太理解,故查询了相关文档后,将心得记录一下 ...

  3. 【编程拾遗】C++的static成员函数与单例模式

    static小结 static的引入 static 是C++中非经常常使用的修饰符,它被用来控制变量的存储方式和可见性. 函数内部定义的变量,在程序运行到它的定义处时,编译器为它在栈上分配空间,函数在 ...

  4. 启用Win10家庭版的远程桌面服务端

    1,使用工具:下载地址:https://github.com/binarymaster/rdpwrap/releases 参考资料: https://blog.csdn.net/BaoBeiDeXia ...

  5. Windows中Anaconda,Tensorflow 和 Pycharm的安装和配置

    Anaconda完全入门指南 https://www.jianshu.com/p/eaee1fadc1e9                 [安装不要按此条链接进行] Windows中 Anacond ...

  6. Python 标准异常总结

    AssertionError 断言语句(assert) AttributeError 尝试访问未知的对象属性 EOFError 用户输入文件末尾标志EOF(Ctrl+d) FloatingPointE ...

  7. vue之登录和token处理

    应用场景一 Vue刷新token,判断token是否过期.失效,进行登录判断跟token值存储 刷新token和token是否过期的操作都是由后端实现,前端只负责根据code的不同状态来做不同的操作: ...

  8. OninitDialog与OnCreate两个消息有何区别

    WM_INITDIALOGThe WM_INITDIALOG message is sent to the dialog box procedure immediately before a dial ...

  9. 【转】Linux下gcc生成和使用静态库和动态库详解

    一.基本概念 1.1 什么是库 在Windows平台和Linux平台下都大量存在着库. 本质上来说,库是一种可执行代码的二进制形式,可以被操作系统载入内存执行. 由于windows和linux的平台不 ...

  10. 简单的三级联动demo

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...