1.源码安装MySQL5.6

# CentOS6操作系统安装完成后,默认会在/etc目录下存在一个my.cnf,
# 强制卸载了mysql-libs之后,my.cnf就会消失
rpm -qa | grep mysql
rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
yum -y install make gcc-c++ cmake bison-devel ncurses-devel groupadd mysql
useradd -g mysql mysql -M -s /sbin/nologin
mkdir -p /server/tools
cd /server/tools
wget http://cdn.mysql.com//archives/mysql-5.6/mysql-5.6.21.tar.gz
tar xf mysql-5.6.21.tar.gz
mv /server/tools/mysql-5.6.21 /opt/mysql-5.6.21/
ln -s /opt/mysql-5.6.21/ /application/mysql
cd /application/mysql/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql/data \
-DSYSCONFDIR=/usr/local/mysql -DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/var/mysql.sock \
-DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
make && make install CMake Warning:
Manually-specified variables were not used by the project:
WITH_READLINE
WITH_MEMORY_STORAGE_ENGINE
CMake Warning手动指定的变量未被项目使用,在这里倒没什么事

目录说明:

a.安装完成后不会生成配置文件,不会给你创建/usr/local/mysql/var/目录,

不会给你创建/data/mysql/data,这些都需要手动创建;

b./opt/mysql-5.6.21/是解压目录;

c.-DCMAKE_INSTALL_PREFIX=/usr/local/mysql/是所有配置文件存放目录;

d.-DMYSQL_DATADIR=/data/mysql/data/是数据及日志存放目录;

e.-DSYSCONFDIR=/usr/local/mysql是my.cnf存放目录;

f.-DMYSQL_UNIX_ADDR是socket存放目录.

2.配置并启动

mkdir -p /data/mysql/data
mkdir -p /usr/local/mysql/var
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /data/mysql/data
cd /usr/local/mysql
# 如果不小心删除了这个数据目录或这个目录下的文件被误操作删除了,可以利用这个命令重新初始化
./scripts/mysql_install_db --basedir=/usr/local/mysql \
--datadir=/data/mysql/data --user=mysql
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig mysqld on
echo "export PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile
source /etc/profile

my.cnf

cat > /usr/local/mysql/my.cnf << EOF
[client]
port = 3306
socket = /usr/local/mysql/var/mysql.sock [mysqld]
port = 3306
socket = /usr/local/mysql/var/mysql.sock basedir = /usr/local/mysql
datadir = /data/mysql/data
pid-file = /data/mysql/data/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1
sync_binlog=1
log_bin = mysql-bin skip-name-resolve
#skip-networking
back_log = 600 max_connections = 3000
max_connect_errors = 3000
##open_files_limit = 65535
table_open_cache = 512
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 = 8 query_cache_size = 512M
query_cache_limit = 1024M ft_min_word_len = 4 binlog_format = mixed
expire_logs_days = 30 log_error = /data/mysql/data/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/data/mysql-slow.log performance_schema = 0
explicit_defaults_for_timestamp ##lower_case_table_names = 1 skip-external-locking default_storage_engine = InnoDB
##default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 4096M
innodb_write_io_threads = 1000
innodb_read_io_threads = 1000
innodb_thread_concurrency = 8
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 4M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120 bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 2G
myisam_repair_threads = 1 interactive_timeout = 28800
wait_timeout = 28800 [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 = 3306
EOF

3.授权

# 第一次给root设置密码
mysqladmin -u root password 'oldboy123'
# 给root修改密码
mysqladmin -uroot -poldboy123 password'oldboy123456'
# 设置root用户可以远程访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Root123!@#' WITH GRANT OPTION;
FLUSH PRIVILEGES;

4.注意事项及常见报错

a.在启动MySQL服务时,会按照一定次序搜索my.cnf,先在/etc目录下找,找不到,则会搜索"$basedir/my.cnf",
在本例中就是 /usr/local/mysql/my.cnf,这是新版MySQL的配置文件的默认位置; b.在CentOS 6.4版操作系统最小安装完成后,默认会在/etc目录下存在一个my.cnf,
需要将此文件更名为其他的名字,如:/etc/my.cnf.bak(上面的强制卸载,已经把这个文件给删了)
否则,该文件会干扰源码安装的MySQL的正确配置,造成无法启动; c.在使用"yum update"更新系统后,需要检查下/etc目录下是否会多出一个my.cnf,如果多出,
将它重命名成别的.否则,MySQL将使用这个配置文件启动,可能造成无法正常启动等问题. d.用ps -ef查看mysql进程,出现两条斜线是因为配置文件中多加了一个斜线:
basedir = /usr/local/mysql/
/usr/local/mysql//bin/mysqld_safe

e.登陆mysql,若是报错如下:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
解决办法:

mkdir /var/lib/mysql/

ln -s /usr/local/mysql/var/mysql.sock /var/lib/mysql/mysql.sock

f.如果启动报错:

service mysql start

Starting MySQL.Logging to '/data/mysql/data/mysql-error.log'.

mysqld_safe Directory '/usr/local/mysql/var' for UNIX socket file don't exists.

ERROR! The server quit without updating PID file (/data/mysql/data/mysql.pid).

解决办法:

mkdir /usr/local/mysql/var
chown -R mysql:mysql /usr/local/mysql
service mysql start
出这个错的原因应该是:在cmake的时候这一句---DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock
导致的,改成指向配置文件中的就应该不会再报错了.

5.centos7下启动mysql时的一个报错

service mysql start

mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log',

mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log',however file don't exists.

Create writable for user 'mysql'.The server quit without updating PID file (/data/mysql/data[FAILED]id).

该问题为mysql的一个小bug,临时处理办法为:直接创建一个 log-error 指定的空文件,

并给适当的属主、属组权限即可.该问题已经在版本 5.5.55, 5.6.36, 5.7.18, 8.0.1中修复.

mkdir -p /var/log/mariadb
touch /var/log/mariadb/mariadb.log
chown -R mysql.mysql /var/log/mariadb
service mysql start
ln -s /var/log/mariadb/mariadb.log /data/mysql/data/mysql-error.log
/etc/init.d/mysql restart

参考博客:http://www.cnblogs.com/kevingrace/p/6109679.html

CentOS6.7源码安装MySQL5.6的更多相关文章

  1. CentOS6.5源码安装MySQL5.6.35

    CentOS6.5源码安装MySQL5.6.35 一.卸载旧版本 1.使用下面的命令检查是否安装有mysql [root@localhost tools]# rpm -qa|grep -i mysql ...

  2. CentOS6下源码安装mysql-5.6.25

    1.1.系统环境检查 1)检查系统版本 mkdir -p /server/tools/ cd /server/tools/ cat /etc/redhat-release 2)配置域名解析 vim / ...

  3. CentOS6.5源码安装mysql-5.5.21

    本文参考自 http://www.cnblogs.com/ShanFish/p/6531365.html,但不局限于它. 一. 卸载旧版本 .检查是否安装mysql组件 # rpm -qa | gre ...

  4. CENTOS6.5源码安装LNMP

    CENTOS6.5源码安装LNMP 一.安装前准备 ########################################################################## ...

  5. lnmp之阿里云源码安装mysql5.7.17

    mysql5.7.17一直号称世界上最好的mysql 那么就在阿里云主机linux安装它(采用的源码安装mysql5.7.17) 我在阿里云主机上安装它 连接阿里云主机 进入,跟我们自己装的虚拟机一毛 ...

  6. CentOS7 实战源码安装mysql5.7.17数据库服务器

    CentOS7 实战源码安装mysql5.7.17数据库服务器 简介:实战演练mysql数据库服务器的搭建  mysql简介: mysql是一个开源的关系型数据库管理系统,现在是oracle公司旗下的 ...

  7. CentOS6.5下源码安装MySQL5.6.35

    接上一篇文章使用RPM包安装MySQL,确实很方便.但是安装后却不知道各文件保存在哪个文件夹下!尝试使用源码安装~本文主要参考:CentOS 6.4下编译安装MySQL 5.6.14一.卸载旧版本 . ...

  8. 搭建LNAMP环境(一)- 源码安装MySQL5.6

    1.yum安装编译mysql需要的包 yum -y install gcc-c++ make cmake bison-devel ncurses-devel perl 2.为mysql创建一个新的用户 ...

  9. CentOS7下源码安装mysql5.6

    目录 准备工作 运行环境 确认你的安装版本 下载mysql 安装mysql 准备安装环境 编译和安装 配置mysql 单实例配置      单实例配置方法          添加防火墙         ...

随机推荐

  1. linux中怎样关闭ICMP回应功能

    引用自:http://blog.csdn.net/qq844352155/article/details/49700121 linux中怎样关闭ICMP回应功能   输入:   echo 1 > ...

  2. UVALive - 8273 Assigning Frequencies (搜索 )

    n个点的一张图,问能否给每个点染上三种颜色中的一种,使得没有相邻的点颜色相同? n <= 35. Sample Input 4 6 6 0 3 1 5 3 2 2 5 0 4 1 0 7 12 ...

  3. zoj 4054

    #define ll long long ; int t; ll ans,tmp; char s[N]; int main() { scanf("%d",&t); whil ...

  4. hdu 4565

    Problem Description A sequence Sn is defined as:Where a, b, n, m are positive integers.┌x┐is the cei ...

  5. 更改activity切换方式

    overridePendingTransition(enterAnim, exitAnim); Intent intent =new Intent(this,item2.class); startAc ...

  6. 请求报文&响应报文

    转自黑马程序员视频教程

  7. 《Scrum实战》第1次课课后任务

    1.必做任务:从知行角度总结T平台 从知行角度总结T平台 头(知识,学习) 做得好的 宣贯会 引入敏捷思想 敏捷宣言 敏捷原则 质量风险前移原则 引入最佳实践 包括了XP的大部分实践 不足 项目管理框 ...

  8. luogu3370 【模板】字符串哈希

    #include <algorithm> #include <iostream> #include <cstring> #include <cstdio> ...

  9. 数据库学习网站和linux学习网站

    Oracle ITPub论坛 http://www.itpub.net 著名IT技术论坛.尤以数据库技术闻名. ITPUB论坛的前身应该是建立在 smiling 的 oracle小组,他们搬家前的主页 ...

  10. python集合、字符编码、bytes与二进制

    集合 用括号表示{ },可以包含多个元素,用逗号分割 用途 用于关系运算 集合特点 1.每个元素是不可变类型 2.没有重复的元素 3.无序 应用 1.set去重 set(names)的功能是将列表转换 ...