mysql一键安装教程 mysql5.1.45全自动安装(编译安装)

一.问题来源
 
安装MySQL如果手动安装一台还可以,但安装多台,手动安装很麻烦,需要编写一个shell程序 install_mysql.sh来进行安装

二.程序说明
 将MySQL5.1.45安装到了 /home/longxibendi/mysql/usrl/local/mysql
 数据文件以及日志文件设置在了 /home/longxibendi/mysql/3309/
 配置文件my.cnf 在   /home/longxibendi/mysql/3309
 端口使用  3309

三.源程序 install_mysql.sh

#!/bin/bash
#author longxibendi
#function install MySQL5.1.45 

###################################### configure and install #####################################################
mkdir -p /home/longxibendi/mysql/usr/local/mysql
cd
mkdir mysql
cd mysql
wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.45.tar.gz 

tar zxvf mysql-5.1.45.tar.gz
cd mysql-5.1.45 

./configure --prefix=/home/longxibendi/mysql/usr/local/mysql --without-debug --without-bench --enable-thread-safe-client --enable-assembler --enable-profiling --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-charset=latin1 --with-extra-charset=utf8,gbk --with-innodb --with-mysqld-user=longxibendi --without-embedded-server --with-server-sufix=community --with-unix-socket-path=/home/longxibendi/mysql/usr/local/mysql/sock/mysql.sock --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-plugins=partition,heap,innobase,myisam,myisammrg,csv
make -j `cat /proc/cpuinfo | grep 'model name' | wc -l ` && make install 

###################################### set log and data storage path ##################################################### 

chmod +w /home/longxibendi/mysql/usr/local/mysql
mkdir -p /home/longxibendi/mysql/3309/data/
mkdir -p /home/longxibendi/mysql/3309/binlog/
mkdir -p /home/longxibendi/mysql/3309/relaylog/ 

###################################### create data file ##################################################### 

/home/longxibendi/mysql/usr/local/mysql/bin/mysql_install_db --basedir=/home/longxibendi/mysql/usr/local/mysql --datadir=/home/longxibendi/mysql/3309/data --user=longxibendi 

####################################### create my.cnf profile ##################################################### 

echo "
[client]
character-set-server = utf8
port  = 3309
socket = /home/longxibendi/mysql/usr/local/mysql/sock/mysql.sock 

[mysqld]
character-set-server = utf8
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user  = mysql
port  = 3309
socket = /home/longxibendi/mysql/usr/local/mysql/sock/mysql.sock
basedir = /home/longxibendi/mysql
datadir = /home/longxibendi/mysql/3309/data
log-error = /home/longxibendi/mysql/3309/mysql_error.log
pid-file = /home/longxibendi/mysql/3309/mysql.pid
open_files_limit  = 10240
back_log = 600
max_connections = 5000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 16M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 300
#thread_concurrency = 8
query_cache_size = 20M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 20M
max_heap_table_size = 20M
long_query_time = 3
log-slave-updates
log-bin = /home/longxibendi/mysql/3309/binlog/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 20M
relay-log-index = /home/longxibendi/mysql/3309/relaylog/relaylog
relay-log-info-file = /home/longxibendi/mysql/3309/relaylog/relaylog
relay-log = /home/longxibendi/mysql/3309/relaylog/relaylog
expire_logs_days = 30
key_buffer_size = 10M
read_buffer_size = 1M
read_rnd_buffer_size = 6M
bulk_insert_buffer_size = 4M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 20M
myisam_repair_threads = 1
myisam_recover 

interactive_timeout = 120
wait_timeout = 120 

skip-name-resolve
#master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396 

#master-host   =  192.168.1.2
#master-user   =  username
#master-password =  password
#master-port   = 3309 

server-id = 1 

innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 20M
innodb_data_file_path = ibdata1:56M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 20M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0 

#log-slow-queries = /home/longxibendi/mysql/3309/slow.log
#long_query_time = 10 

[mysqldump]
quick
max_allowed_packet = 32M 

" > /home/longxibendi/mysql/3309/my.cnf 

############################### solve bug http://bugs.mysql.com/bug.php?id=37942 ############################################# 

mkdir -p /home/longxibendi/mysql/share/mysql/english/
cp /home/longxibendi/mysql/usr/local/mysql/share/mysql/english/errmsg.sys /home/longxibendi/mysql/share/mysql/english/ 

############################### start MySQL Server #############################################
/bin/sh /home/longxibendi/mysql/usr/local/mysql/bin/mysqld_safe --defaults-file=/home/longxibendi/mysql/3309/my.cnf 2>&1 > /dev/null &
############################### try use MySQL Server #############################################
/home/longxibendi/mysql/usr/local/mysql/bin/mysql -u root -p -S /home/longxibendi/mysql/usr/local/mysql/sock/mysql.sock -P3309 -h127.0.0.1 -e "show databases;"
#!/bin/bash
#author longxibendi
#function install MySQL5.1.45

###################################### configure and install #####################################################
mkdir -p /home/longxibendi/mysql/usr/local/mysql
cd
mkdir mysql
cd mysql
wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.45.tar.gz

tar zxvf mysql-5.1.45.tar.gz
cd mysql-5.1.45

./configure --prefix=/home/longxibendi/mysql/usr/local/mysql --without-debug --without-bench --enable-thread-safe-client --enable-assembler --enable-profiling --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-charset=latin1 --with-extra-charset=utf8,gbk --with-innodb --with-mysqld-user=longxibendi --without-embedded-server --with-server-sufix=community --with-unix-socket-path=/home/longxibendi/mysql/usr/local/mysql/sock/mysql.sock --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-plugins=partition,heap,innobase,myisam,myisammrg,csv
make -j `cat /proc/cpuinfo | grep 'model name' | wc -l ` && make install

###################################### set log and data storage path #####################################################

chmod +w /home/longxibendi/mysql/usr/local/mysql
mkdir -p /home/longxibendi/mysql/3309/data/
mkdir -p /home/longxibendi/mysql/3309/binlog/
mkdir -p /home/longxibendi/mysql/3309/relaylog/

###################################### create data file #####################################################

/home/longxibendi/mysql/usr/local/mysql/bin/mysql_install_db --basedir=/home/longxibendi/mysql/usr/local/mysql --datadir=/home/longxibendi/mysql/3309/data --user=longxibendi

####################################### create my.cnf profile #####################################################

echo "
[client]
character-set-server = utf8
port  = 3309
socket = /home/longxibendi/mysql/usr/local/mysql/sock/mysql.sock

[mysqld]
character-set-server = utf8
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user  = mysql
port  = 3309
socket = /home/longxibendi/mysql/usr/local/mysql/sock/mysql.sock
basedir = /home/longxibendi/mysql
datadir = /home/longxibendi/mysql/3309/data
log-error = /home/longxibendi/mysql/3309/mysql_error.log
pid-file = /home/longxibendi/mysql/3309/mysql.pid
open_files_limit  = 10240
back_log = 600
max_connections = 5000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 16M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 300
#thread_concurrency = 8
query_cache_size = 20M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
default-storage-engine = MyISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 20M
max_heap_table_size = 20M
long_query_time = 3
log-slave-updates
log-bin = /home/longxibendi/mysql/3309/binlog/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 20M
relay-log-index = /home/longxibendi/mysql/3309/relaylog/relaylog
relay-log-info-file = /home/longxibendi/mysql/3309/relaylog/relaylog
relay-log = /home/longxibendi/mysql/3309/relaylog/relaylog
expire_logs_days = 30
key_buffer_size = 10M
read_buffer_size = 1M
read_rnd_buffer_size = 6M
bulk_insert_buffer_size = 4M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 20M
myisam_repair_threads = 1
myisam_recover

interactive_timeout = 120
wait_timeout = 120

skip-name-resolve
#master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

#master-host   =  192.168.1.2
#master-user   =  username
#master-password =  password
#master-port   = 3309

server-id = 1

innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 20M
innodb_data_file_path = ibdata1:56M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 20M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0

#log-slow-queries = /home/longxibendi/mysql/3309/slow.log
#long_query_time = 10

[mysqldump]
quick
max_allowed_packet = 32M

" > /home/longxibendi/mysql/3309/my.cnf

############################### solve bug http://bugs.mysql.com/bug.php?id=37942 #############################################

mkdir -p /home/longxibendi/mysql/share/mysql/english/
cp /home/longxibendi/mysql/usr/local/mysql/share/mysql/english/errmsg.sys /home/longxibendi/mysql/share/mysql/english/

############################### start MySQL Server #############################################
/bin/sh /home/longxibendi/mysql/usr/local/mysql/bin/mysqld_safe --defaults-file=/home/longxibendi/mysql/3309/my.cnf 2>&1 > /dev/null &
############################### try use MySQL Server #############################################
/home/longxibendi/mysql/usr/local/mysql/bin/mysql -u root -p -S /home/longxibendi/mysql/usr/local/mysql/sock/mysql.sock -P3309 -h127.0.0.1 -e "show databases;"

四.成功安装结果

当安装完成之后,直接回车,就可以看到以下信息
 information_schema
 mysql
 test

以上就是mysql 5.1.45编译安装配置方法,希望对大家的学习有所帮助。

(0)

相关推荐

  • mysql安装配置详解教程(一)

    MySQL数据库具有跨平台性,不仅可以在Windows上运行,还可以在UNIX,Linux和Mac OS等操作系统上运行 1.先简单说下MySQL的版本: 根据操作系统的类型可分为:Windows版.UNIX版.Linux版和Mac OS版 根据用户群体的不同可分为:社区版(Community Edition)和企业版(Enterprise),社区版完全免费,企业版是收费的 根据发布顺序来区分可分为:4.1.5.0.5.1.5.4.6.0等版本 根据MySQL的开发情况分为:Alpha.Beta

  • mysql5.7数据库安装完成后如何配置环境变量

    如果我们在windows10系统中安装mysql后,没有配置环境变量的话,在使用命令行进行mysql操作时就必须要进入mysql安装目录才行.这样操作起来感觉会非常麻烦.这该怎么办呢?win10系统中配置mysql环境变量的方法. 方法/步骤: 键盘组合键:Win+i,打开设置窗口,点击"系统",进入系统设置 点击打开后,在系统设置窗口中选择"关于"-"系统信息", 在出现的窗口中选择"高级系统设置": 在"系统属性

  • mysql 5.7.11 winx64快速安装配置教程

    本文为大家分享了mysql 5.7.11安装配置方法,供大家参考,具体内容如下 一.安装总体思路: 在官网下载zip安装包: 解压拷贝到C盘下: 配置环境变量: 修改mysql根目录下配置文件my-default.ini: 初始化mysql,安装mysql,启动mysql服务: 修改root用户密码: 成功安装. 二.具体步骤说明 1.下载安装包. 2.拷贝到C盘: 解压后拷贝文件夹至C盘:C:\Program Files\mysql.建议文件夹名字简单些. 3.配置环境变量: 计算机->右键-

  • mysql 5.7.11 安装配置教程

    六步轻松搞定mysql5.7.11的安装 1.下载安装包.mysql-5.7.11版本: 2.拷贝到任意盘: 例如,解压后拷贝文件夹至C盘:C:\Program Files\mysql.建议文件夹名字使用英文. 3.配置环境变量: 计算机->右键->高级系统设置->高级->环境变量->修改Path,将地址栏"C:\Program Files\mysql\bin;"粘贴到最后,注意:不同的路径之间用英文的";"分开,确定,退出. 4.修改

  • 解决mysql安装时出现error Nr.1045问题的方法

    我们在windows下安装MySQL时会出现Access denied for user 'root'@localhost'(using password:No)的问题,这个问题是因为你的机器上之前安装过mysql,或者这 一次安装配置了新密码,进入应用的最后一步时候由于某些原因卡出了或者由于服务未启动等原因导致无法配置成功,最终结果是,配置未成功,密码设置已经保存 进去了.这样我们调整好了服务等原因后,进行重新配置的时候,会发现在设置密码的时候,多了一个旧密码输入框.其实这也没什么,在密码知道

  • windows server 2008/2012安装php iis7 mysql环境搭建教程

    windows server 2008/2012安装php iis7 mysql环境搭建教程,具体内容如下 1.安装IIS windows server 2008的IIS版本为7.0,包括fastcgi,安装十分方便. 打开"开始"菜单→"服务器管理",出现服务器管理界面(图1) 图1 - 服务器管理 滚动条下翻,或者点击主菜单的"角色",然后点击"添加角色",出现向导页面后点击下一步,选择"web服务器(IIS)&

  • Mysql下载安装、部署与图形化详细操作教程

    Mysql是一个必须学会如何安装与部署的工具,它不同于其它那些傻瓜式的应用/程序,一键到底,如果是初次在Windows下安装Mysql的初学者还是有一定难度的. 本文配合之前的<Javaweb开发环境Myeclipse6.5 JDK1.6 Tomcat6.0 SVN1.8配置教程>(点击打开链接)一文中的前台开发环境的部署,也就形成了JavaWeb.JSP.J2EE的基本开发环境. 一.Mysql的下载 首先打开Mysql的官网(点击打开链接),百度一下是搜不到的,我也找了很久才找到Mysql

  • python安装mysql-python简明笔记(ubuntu环境)

    本文讲述了python安装mysql-python的方法.分享给大家供大家参考,具体如下: ubuntu 系统下进行的操作 首先安装了pip工具 sudo apt-get install python-pip 然后使用 sudo pip install mysql-python 安装第三方库.但是此时报错 sh: mysql_config: not found Traceback (most recent call last): File "setup.py", line 15, in

  • 解决MySQL安装重装时出现could not start the service mysql error:0问题的方法

    当各位在安装.重装时出现could not start the service mysql error:0 原因: 卸载mysql时并没有完全删除相关文件和服务,需要手动清除. 安装到最后一步execute时不能启动服务的解决方法: 首先,在管理工具->服务里面将MySQL的服务给停止(有的是没有安装成功,有这个服务,但是已经停止了的),win+R->cmd,打开命令提示符窗口,输入命令:sc delete mysql(查看服务,此时服务中已没有mysql),将已停的服务删除,卸载MySQL记

  • Linux环境mysql5.7.12安装教程

    在Linux上安装MySQL  环境:windows7  虚拟机:Oracle VMVirtualBox  Linux: ubuntukylin-14.04.1-amd64.iso  mysql:5.7.12  一.环境准备  step1:安装虚拟机  step2:修改宿主机BIOS配置 操作系统:Windows 7 64位: 虚拟机:Oracle VM VirtualBox  Linux版本: Ubuntu4.0  64  问题描述:新建虚拟机的列表中没有64位系统选项 解决方法:修改机器中的

  • MySQL5.5.21安装配置教程(win7)

    Win7安装mysql的具体过程,我的版本是5.5.21 以下是我的安装步骤: 1.首先单击MySQL5.5.21的安装文件,出现该数据库的安装向导界面,单击"next"继续安装,如图所示: 2.在打开的窗口中,选择接受安装协议,单击"next"继续安装,如图所示: 3.在出现选择安装类型的窗口中,有"typical(默认)"."Complete(完全)"."Custom(用户自定义)"三个选项,我们选择&

  • MySQL的源码安装及使用UDFs进行数据自动更新的教程

    MySQL的源码安装 1. 安装依赖组件 # yum install gcc gcc-c++ ncurses-devel perl -y 2. 安装cmake # wget http://www.cmake.org/files/v2.8/cmake-2.8.12.tar.gz # tar zxvf cmake-2.8.12.tar.gz # cd cmake-2.8.12 # ./bootstrap # make && make install 3. 安装bison # wget http

  • mysql 5.6.17 绿色版(免安装)安装配置教程

    最近在做项目开发时用到了MySql数据库,在看了一些有关MySql的文章后,很快就上手使用了.在使用的过程中还是出现了一些问题,因为使用的是绿色免安装版的MySql所以在配置的时候出现了一些问题,该篇文章就主要针对MySql绿色版的配置及其使用进行讨论. 一.MySql概述        MySql数据库是有瑞典MySql AB公司开发,现在该公司被Oracle收购属于Oracle所有.同SQL Server类似,它也是基于关系型数据库的数据库管理系统,在Web应用方面MySQL是最好的RDBM

  • mysql 5.7.13 安装配置笔记(Mac os)

    一.MySQL5.7.13安装 到MySQL官网上http://dev.mysql.com/downloads/mysql/,下载mysql可安装dmg版本 mysql-5.7.13-osx10.11-x86_64 .dmg 下载完的文件为:mysql-5.7.13-osx10.11-x86_64 .dmg 点击安装包一步步傻瓜式安装就行. 系统偏好设置的其他里,点击"mysql"的图标 点击Start MySQL Server按钮,启动mysql 二.打开终端,定义MySQL别名 输

  • MySql5.6使用validate password 插件加强密码强度的安装及使用方法

    mysql 5.6对密码的强度进行了加强,推出了 validate_password 插件.支持密码的强度要求. 安装办法: 在配置文件中打开 [mysqld] plugin-load=validate_password.so validate-password=FORCE_PLUS_PERMANENT validate_password_policy=2 并装载plugin: mysql>>INSTALL PLUGIN validate_password SONAME 'validate_p

随机推荐