MySQL---source installation

Source: Internet
Author: User


1. Install dependent packages

[email protected] mysql-5.1.50]# yum-y install gcc gcc-c++ ncurses ncurses-devel OpenSSL openssl-devel libtool*
2. Create User
[[email protected] mysql-5.1.50]# Groupadd MySQL
[Email protected] mysql-5.1.50]# useradd mysql-g mysql-s/sbin/nologin
3. Install MySQL
[Email protected] mysql]# Tar XF mysql-5.1.50.tar.gz
[Email protected] mysql]# CD mysql-5.1.50
[email protected] mysql-5.1.50]#/configure '--prefix=/usr/local/services/mysql '--localstatedir=/data/ dbdata/'--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock '--with-charset=utf8 '--with-extra-charsets= Complex '--with-pthread '--enable-thread-safe-client '--with-ssl '--with-client-ldflags=-all-static '-- With-mysqld-ldflags=-all-static '--with-plugins=partition,federated,ndbcluster,innobase,csv,blackhole,myisam, Innodb_plugin,heap,archive '--enable-shared '--enable-assembler '

detailed
--prefix------"Specify Mysql installation directory (required)
--localstatedir------Specify MySQL data storage directory (required)
--with-unix-socket-path-----"Execution Socke storage location (required)
--with-charset-----"Specify the default character set
--with-extra-charsets-----"can extend complex character sets
--with-pthread forcing the use of the Pthread class library
--enable-thread-safe-client using the compile client; (Let the client support thread meaning)
--WITH-SSL support for SSL enabled
--with-client-ldflags=-all-static statically compiled MySQL client; (static link improves 13% performance)
--with-mysqld-ldflags=-all-static statically compiled MySQL server side; (static link improves 13% performance)
--with-plugins-----"MySQL server-side supported storage engine
--enable-shared Shared Mutation Module
--enable-assembler using assembly mode for increased efficiency
For more details, refer to: http://2999835.blog.51cto.com/2989835/1376960
4. Initialize
[Email protected] mysql-5.1.50]# mkdir/data/dbdata-p-----"Creating a MySQL data store directory
[Email protected] mysql-5.1.50]# chown-r mysql:mysql/data/dbdata/----"Authorized
[Email protected] mysql-5.1.50]# chown-r mysql:mysql/usr/local/services/mysql----"Authorized
[Email protected] mysql-5.1.50]#/usr/local/services/mysql/bin/mysql_install_db--user=mysql--basedir=/usr/local/ Services/mysql--datadir=/data/dbdata/------"Start initializing
[Email protected] mysql-5.1.50]# Cp/usr/local/services/mysql/share/mysql/mysql.server/etc/init.d/mysqld
[Email protected] mysql-5.1.50]# chmod 755/etc/init.d/mysqld
[Email protected] ~]# vim/etc/init.d/mysqld--------> Modify Startup Scripts
Basedir=/usr/local/services/mysql
datadir=/data/dbdata/

5. Configuration Files
[Email protected] mysql]# cp/mysql/my.cnf/etc/my.cnf——— "This is your own configuration file.
[Email protected] mysql]# VIM/ETC/MY.CNF
[Client]
Port = 3306 #客户端连接端口3306 (can be changed)
socket =/usr/local/mysql/tmp/mysql.sock # (connect sock location)
[Mysqld]
datadir=/data/dbdata/#数据库存放目录
Skip-name-resolve #garnt时, IP must be used and host name cannot be used
Lower_case_table_names=1 #不区分大小写
Innodb_file_per_table=1 #可以修改InnoDB为独立表空间模式, each table in each database generates a data space
Expire_logs_days = Ten #binlog日志保留10天
Federated #本地MySQL数据库要访问远程MySQL数据库的表中的数据 must be implemented through the Federated storage Engine
Port = 3306 # Mysql Port default 3306, can modify socket =/usr/local/mysql/tmp/mysql.sock #Mysql define where sock is stored
Back_log = #在MySQL的连接请求等待队列中允许存放的最大连接请求数. System default value is 50
Max_connections = #最大并发连接数, increasing this value requires a corresponding increase in the number of file descriptors allowed to open max_connect_errors = #如果某个用户发起的连接error超过该数值, the next time the user's connection will be blocked, Table_open_cache = 2048 # Table_open_cache: Table descriptor cache size to reduce file open/close times
Max_allowed_packet = 16M #将发出 "Packet too Large" error and close connection, default value 16M
Binlog_cache_size = 2M #限制其最大大小 (MySQL will request more memory when a single transaction is too Large)
Max_heap_table_size = 64M #内存表的大小
Sort_buffer_size = 8M #MyISAM表发生变化时重新排序所需的缓冲. General 64M is sufficient
Join_buffer_size = 4M # InnoDB is used to cache data and
Thread_cache_size = 64 # Cache The number of reusable threads that can be adjusted appropriately
Thread_concurrency = 8 #这个是innodb内核的并发线程处理参数, the front end has 100 connections, and 1000 SQL is sent, if this parameter is set to 2. So in these 1000 sql, up to 2 SQL runs in the InnoDB kernel. Everything else has to wait. (In fact, the process is complex, so you can understand that not all SQL needs to be handled by the InnoDB kernel)
Query_cache_size = 128M #指定MySQL查询结果缓冲区的大小. Tuning can be adjusted appropriately
Query_cache_limit = 2M #缓存单条SQL的结果集上限. Default 4KB. Tuning can be adjusted appropriately
Ft_min_word_len = 4 #指定被索引的关键词的最小长度. Note: After changing the parameter value, the index must be rebuilt! Note This value is set well after. Do not modify it arbitrarily
Default-storage-engine = InnoDB #默认引擎使用innodb
Thread_stack = 192K #应小于可用内存保持默认
Transaction_isolation = Repeatable-read #设定默认的事务隔离级别
Tmp_table_size = 128M # internal (in-memory) the maximum size of a temporary table if a table grows larger than this value, it is automatically converted to a disk-based table. This limit is for a single table
Log-bin=mysql-bin # Turn on the binary logging feature. Note This feature must be turned on
Binlog_format=mixed #Mysql主从复制参数, must be turned on
Slow_query_log #开启慢日志
Long_query_time = 2 #命令耗时大于2秒的记录
Server-id = 1 #主从复制唯一的服务辨识号, the value is between 1 and 2^32-1. Ignoring this option, MySQL does not take effect as master, and the smaller the priority the higher it becomes master
Key_buffer_size = 8M #关键词缓冲的大小, commonly used to buffer the index block of a MyISAM table
Read_buffer_size = 2M # The buffer size used to do the MyISAM table full table scan.
Read_rnd_buffer_size = 2M #当在排序之后, when reading rows from a sorted sequence, row data is read from this buffer to prevent disk seek
Bulk_insert_buffer_size = 64M # This buffer is allocated for MyISAM when burst insertion is detected
Myisam_sort_buffer_size = 128M # This is assigned in each thread. So be careful when setting large values
myisam_max_sort_file_size = 10G # mysql The size of the maximum temporary file allowed when rebuilding an index if the file size is larger than this value, the index is created by the key buffer (slower)
Myisam_repair_threads = 1 #如果一个表拥有超过一个索引, MyISAM can use more than one thread to fix them by parallel ordering
Myisam_recover # automatic check and fix MyISAM table without proper shutdown
Innodb_additional_mem_pool_size = 32M #附加的内存池被InnoDB用来保存 metadata information, normal remains the default
Innodb_buffer_pool_size = 2g# InnoDB uses a buffer pool to hold indexes and raw data, the larger the disk I/O required, the 70% of the server's physical memory size
Innodb_data_file_path = Ibdata1:10m:autoextend #如果你只有单个逻辑驱动保存你的数据, a single self-increment file is good enough.
Innodb_file_io_threads = 8 # The number of IO threads used to synchronize IO operations
Innodb_thread_concurrency = 16 # The number of allowed threads in the InnoDB core may cause mutually exclusive bumps on the thread

Innodb_flush_log_at_trx_commit = 2 # 0 indicates that the log is only about every second written to the log file and the log file is flushed to disk # 2 for log write log files after each commit, but the log files are flushed to disk only about once per second
Innodb_log_buffer_size = 16m# the size of the buffer used to buffer the log data. When this value is nearly full, INNODB will have to flush the data to disk
Innodb_log_file_size = 512M #在日志组中每个日志文件的大小,
Innodb_log_files_in_group = 3 # The total number of files in the log group. Usually it's better to have one or both.
innodb_max_dirty_pages_pct = #在InnoDB缓冲池中最大允许的脏页面的比例. 60-90 All can
Innodb_lock_wait_timeout = #在被回滚前, how long a InnoDB transaction should wait for a lock to be approved
[Mysqldump]
Quick # do not cache the entire result in memory before it is written to disk. This is required when exporting very large tables
Max_allowed_packet = 256M # Each connection has a separate size. Dynamic Increase in size
[MySQL]
Auto-rehash #可以在命令可以使用tab键补齐
Prompt=\\[email protected]\\d \\r:\\m> #在Mysql命令显示主机名字
[Myisamchk]
Key_buffer_size = 512M # MyISAM uses a special tree-like cache to make a burst insert
Sort_buffer_size = 512M # This is assigned in each thread. So be careful when setting large values
Read_buffer = 8M # The buffer R size used to do myisam table full table scan. When a full table scan is required, assign it in the corresponding thread
Write_buffer = 8M # The buffer w size used to do myisam table full table scan. When a full table scan is required, assign it in the corresponding thread
[Mysqlhotcopy]
Interactive-timeout #服务器关闭交互式连接前等待活动的秒数参数默认值: 28,800 seconds (8 hours)
[Mysqld_safe]
Open-files-limit = 8192 #设置打开文件的句柄数量, in the system can be used Ulimit–a view


6. Start service and set environment variables
[Email protected] mysql]# Vim/etc/profile
Mysql=/usr/local/services/mysql/bin
Path= $PATH: $MYSQL
Export PATH
[Email protected] mysql]# echo $PATH
/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[Email protected] mysql]# Source/etc/profile
[Email protected] mysql]# echo $PATH
/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/services /mysql/bin

Start the service
[[email protected] mysql]#/etc/init.d/mysqld start
Starting MySQL ..... Manager of Pid-file quit without Updat[FAILED].
[Email protected] dbdata]# Cat/data/dbdata/localhost.localdomain.err------"Check the error log
。。。。。。。
141026 4:10:35 [ERROR] Can ' t start server:bind on UNIX socket:no such file or directory
141026 4:10:35 [ERROR] Do you already has another MYSQLD server running on socket:/usr/local/mysql/tmp/mysql.sock?
141026 4:10:35 [ERROR] aborting

Solutions
[Email protected] mysql]# mkdir/usr/local/mysql/tmp/-P
[Email protected] mysql]# chown-r mysql:mysql/usr/local/mysql/tmp/
[[email protected] mysql]#/etc/init.d/mysqld start
Starting MySQL. [OK]
[[email protected] mysql]# MySQL------"Running MySQL
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 1
Server Version:5.1.50-log Source Distribution

Copyright (c), Oracle and/or its affiliates. All rights reserved.
This software comes with absolutely NO WARRANTY. This is the free software,
And you is welcome to modify and redistribute it under the GPL v2 license

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

[Email protected] (none) 18:21>

MySQL---source installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.