`
85977328
  • 浏览: 1869850 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

MYSQL使用心得(一)----centOS or ubuntu下安装mysql5.6

 
阅读更多
官方网站
http://www.mysql.com/
下载
downloads(GA)--> MySQL Community Edition (GPL)

安装依赖
centos
yum install gcc gcc-c++ ncurses-devel zip make cmake
ubuntu
apt-get install gcc g++ cmake make libncurses5-dev bison zip

解压缩
tar -zxvf mysql-5.6.14.tar.gz

注意:
源码目录和安装目录不要使用同一目录!

清理环境
rm -rf /etc/my.cnf
userdel mysql
groupdel mysql

安装mysql
cmake -DCMAKE_INSTALL_PREFIX=/application/search/mysql/mysql-5.6.14 \
-DMYSQL_DATADIR=/data0/search/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1

注:如果想重新cmake,则需要删除目录下的 rm -rf CMakeCache.txt
make -j16 && make install -j16

=====================================================
修改配置文件 /application/search/mysql/mysql-5.6.14/tmp/my.cnf
配置文件是5.5和5.6最关键的区别
=====================================================
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

# 用户客户端bin目录下直接登录使用
[client]
port            = 3306
socket          = /application/search/mysql/mysql-5.6.14/tmp/mysql.sock

[mysql]
default-character-set=utf8

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 1024M
innodb_data_file_path = ibdata1:64M:autoextend
innodb_log_file_size = 1G
innodb_log_files_in_group = 3

innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 0

innodb_use_sys_malloc = 0
# Additional memory pool that is used by InnoDB to store metadata
# information.  If InnoDB requires more memory for this purpose it will
# start to allocate it from the OS.  As this is fast enough on most
# recent operating systems, you normally do not need to change this
# value. SHOW INNODB STATUS will display the current amount used.
innodb_additional_mem_pool_size = 16M
# If you run into InnoDB tablespace corruption, setting this to a nonzero
# value will likely help you to dump your tables. Start from value 1 and
# increase it until you're able to dump the table successfully.
#innodb_force_recovery=1

# Number of threads allowed inside the InnoDB kernel. The optimal value
# depends highly on the application, hardware as well as the OS
# scheduler properties. A too high value may lead to thread thrashing.
innodb_thread_concurrency = 16
# Set this option if you would like the InnoDB tablespace files to be
# stored in another location. By default this is the MySQL datadir.
#innodb_data_home_dir = <directory>

# Number of IO threads to use for async IO operations. This value is
# hardcoded to 8 on Unix, but on Windows disk I/O may benefit from a
# larger number.
innodb_write_io_threads = 8
innodb_read_io_threads = 8

#去掉警告 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.Please use --explicit_defaults_for_timestamp server option (seedocumentation for more details).
explicit_defaults_for_timestamp = true

# These are commonly set, remove the # and set as required.
basedir = /application/search/mysql/mysql-5.6.14
datadir = /data0/search/mysql/data
port = 3306
server_id = 1
socket = /application/search/mysql/mysql-5.6.14/tmp/mysql.sock

pid-file=/application/search/mysql/mysql-5.6.14/tmp/mysqld.pid
log-bin=/data0/search/mysql/log/mysql-bin
relay_log=/data0/search/mysql/log/mysql-relay-bin
log-error=/data0/search/mysql/log/mysqld.err

character-set-server=utf8
default-storage-engine=INNODB
skip-host-cache
skip-name-resolve

innodb_file_per_table=1
expire_logs_days = 10

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
==========================================

手工创建目录,不创建会报错
mkdir -p /data0/search/mysql/data
mkdir -p /data0/search/mysql/log

初始化mysql数据文件及日志文件
cd /application/search/mysql/mysql-5.6.14/scripts
./mysql_install_db --basedir=/application/search/mysql/mysql-5.6.14 --datadir=/data0/search/mysql/data --user=search --defaults-file=/application/search/mysql/mysql-5.6.14/tmp/my.cnf

安装完之后,会提示
New default config file was created as /root/usr/mysql/mysql-5.6.14/my.cnf and will be used by default by the server when you start it.You may edit this file to change server settings
${mysql_home}下的my.cnf会作为默认的配置文件使用
因此我们需要删除${mysql_home}/my.cnf

然后在mysql/bin/mysql --help的时候可以看到一句话
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /root/usr/mysql/mysql-5.6.14/etc/my.cnf ~/.my.cnf
因此我们放到
${mysql_home}/etc/my.cnf
位置是理想的

启动脚本/application/search/mysql/mysql-5.6.14/support-files/mysql.server需要修改才可以使用
非mysql账户启动,参考http://blog.csdn.net/liuguxing/article/details/8835330
因为mysqld_safe启动时默认用的用户是mysql,而脚本中没有指定--user,所以可自行修改脚本,在mysqld_safe命令处(在5.6.14中是第283行)加上参数:--user=root
cd /application/search/mysql/mysql-5.6.14/support-files
cp mysql.server ../mysql.server

起停一 ${mysql_home}/bin命令
./bin/mysqld -uroot &
./bin/mysqladmin shutdown -uroot

起停二 使用脚本${mysql_home}/support-files/mysql.server
sh mysql.server start
sh mysql.server stop

附录
安装 cmake http://phl.iteye.com/blog/1974496
1
3
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics