MysqL 安装

系统平台:CentOS release 6.6 (Final) 64位。

一、安装编译工具及库文件

yum -y install gcc gccc++ make autoconf libtoolltdldevel gddevel freetypedevel libxml2devel libjpegdevel libpngdevel openssldevel curldevel bison patch unzip libmcryptdevel libmhashdevel ncursesdevel sudo bzip2 flex libaiodevel

二、安装cmake 编译器

cmake 版本:cmake-3.1.1。

1、下载地址:http://www.cmake.org/files/v3.1/cmake-3.1.1.tar.gz

$ wgethttp://www.cmake.org/files/v3.1/cmake-3.1.1.tar.gz

2、解压安装包

$ tar zxvf cmake-3.1.1.tar.gz

3、进入安装包目录

$ cd cmake1

4、编译安装

$ ./bootstrap
$ make && make install

三、安装 MysqL

MysqL版本:MysqL-5.6.15。

1、下载地址:http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15.tar.gz

//dev.MysqL.com/get/Downloads/MysqL-5.6/MysqL-5.6.15.tar.gz

$ tar zxvf MysqL5.615.tar$ cd MysqL15

$ cmake DCMAKE_INSTALL_PREFIX=/usr/local/webserverMysqL DMysqL_UNIX_ADDR/tmp/sock DDEFAULT_CHARSET=utf8 DDEFAULT_COLLATIONutf8_general_ci DWITH_EXTRA_CHARSETSall DWITH_MYISAM_STORAGE_ENGINE=1DWITH_INNOBASE_STORAGE_ENGINEDWITH_MEMORY_STORAGE_ENGINEDWITH_READLINEDWITH_INNODB_MEMCACHEDDWITH_DEBUGOFF DWITH_ZLIBbundled DENABLED_LOCAL_INFILEDENABLED_PROFILINGON DMysqL_MAINTAINER_MODEDMysqL_DATADIRdata DMysqL_TCP_PORT3306 $ make make install

5、查看MysqL版本:

usr/binMysqL --version

到此,MysqL安装完成。


MysqL 配置

1、创建MysqL运行使用的用户MysqL

sbingroupadd MysqL
$ useradd g MysqL MysqL

2、创建binlog和库的存储路径并赋予MysqL用户权限

$ mkdir p binlog wwwdata_MysqL
$ chown MysqLbinlog/ /data_MysqL/

3、创建my.cnf配置文件

将/etc/my.cnf替换为下面内容

$ cat etcmycnf

[client]
port  
socket  sock
MysqLd
replicateignoredb  MysqL
replicate test
replicate information_schema
user  MysqL
port sock
basedir MysqL
datadir /www/data_MysqL
logerror MysqL_errorlog
pidfile pid
open_files_limit 65535
back_log 600
max_connections 5000
max_connect_errors 1000
table_open_cache 1024
externallocking  FALSE
max_allowed_packet 32M
sort_buffer_size 1M
join_buffer_size 
thread_cache_size 
#thread_concurrency = 8
query_cache_size 128M
query_cache_limit 2M
query_cache_min_res_unit 2k
defaultstorageengine  MyISAMtmpengineMYISAM
thread_stack 192K
transaction_isolation  READCOMMITTED
tmp_table_size 
max_heap_table_size 
logslaveupdates
logbin binlogbinlog
binlog-dodboa_fb
binlogMysqL
binlog_cache_size 4M
binlog_format  MIXED
max_binlog_cache_size 8M
max_binlog_size 1G
relaylogindex relaylogrelaylog
relayinfolog relaylog
expire_logs_days 10
key_buffer_size 256M
read_buffer_size 
read_rnd_buffer_size 16M
bulk_insert_buffer_size 64M
myisam_sort_buffer_size 
myisam_max_sort_file_size 10G
myisam_repair_threads 
myisam_recover
interactive_timeout 120
wait_timeout 
skipnameresolve
#master-connect-retry = 10
slaveskiperrors 1032,10621261114114610481396#master-host = 192.168.1.2#master-user = username#master-password = password#master-port = 3306
serverid 
looseinnodbtrx0lockslockwaitscmpperindexresetcmpmembufferpagelrupoolstatsmetricsftstopwordinserteddeletedbeingconfigcachetablesystablestablestatsindexescolumnsfieldsforeigncols

slow_query_log_fileMysqL_slowlog
long_query_time 
MysqLdump
quick
max_allowed_packet 32M

4、初始化数据库

$scriptsMysqL_install_db defaultsfile/etc/cnf userMysqL

显示如下信息:

InstallingMysqL system tables...2015012620:1851[Warning TIMESTAMP with implicit DEFAULT value is deprecatedPleaseuseexplicit_defaults_for_timestamp server option (see documentation for more details).
OK

Filling help tables57
OK
...

5、创建开机启动脚本

$ cd 
$ cp supportfilesserver rcdinitMysqLd
$ chkconfig add MysqLd
$ chkconfig level 35 MysqLd on

6、启动MysqL服务器

$ service MysqLd start
如何失败提示:The server quit without updating PID file (/usr/local/webserver/MysqL/MysqL.pid)
解决办法:

#cd /usr/local/webserver/MysqL

#chown -R MysqL.MysqL . (注意最后面有个.) #su - MysqL $scripts/MysqL_install_db

7、连接 MysqL

u root p

修改MysqL用户密码

MysqLadmin u用户名p旧密码 password 新密码

或进入MysqL命令行

SET PASSWORD FOR '用户名'@'主机' PASSWORD(‘密码');

创建新用户并授权:

grant all privileges on *.* to 用户名@'%' identified by'密码' grant option;

其他命令

  • 启动:service MysqLd start
  • 停止:service MysqLd stop
  • 重启:service MysqLdrestart
  • 重载配置:service MysqLdreload

参考链接
http://www.runoob.com/linux/MysqL-install-setup.html
http://blog.sina.com.cn/s/blog_637e04c9010117ri.html