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源码安装LNMP

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

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

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

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

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

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

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

  7. CentOS7下源码安装mysql5.6

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

  8. 记录一个源码安装mysql5.6的方法

    https://www.jb51.net/article/118853.htm 如果之前源码安装过mysql5.6的话,卸载方法如下:rm -rf /var/lib/mysql/rm -rf /usr ...

  9. CentOS 源码安装MySQL5.7

    一.安装方式源码安装,源码包名称mysql-boost-5.7.27.tar.gz,此版本包含boost库,在解压后的boost路径下.安装时,可以-DDOWNLOAD_BOOST=1 -DWITH_ ...

随机推荐

  1. Atitit &#160;rgb yuv &#160;hsv HSL 模式和 HSV(HSB) 图像色彩空间的区别

    Atitit  rgb yuv  hsv HSL 模式和 HSV(HSB) 图像色彩空间的区别 1.1. 色彩的三要素 -- 色相.明度.纯度1 1.2. YUV三个字母中,其中"Y&quo ...

  2. 20145334实验三《敏捷开发与XP实践》

    实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉S.O.L.I.D原则 了解设计模式 实验步骤 1.敏捷开发与XP 敏捷开发(Agile Dev ...

  3. 在ubuntu下安装chrome

    To add PPA in Ubuntu 14.04 / 13.10 / 13.04 / 12.10 / 12.04 First download and install the key from G ...

  4. python---pyc pyo文件详解

    http://blog.csdn.net/balabalamerobert/article/details/2683029#comments http://blog.csdn.net/zhengsen ...

  5. [QuickX]xcode运行Quick-cocos2d-x项目时自动更新lua资源文件

    1.项目设置 build settings ->build options ->Scan all source files and Includes = YES 2.加入script (1 ...

  6. 不用position,让div垂直居中

    先弄懂after伪类的用法,就可以很容易理解了. <!DOCTYPE html> <html lang="en"><head> <meta ...

  7. 6. leetcode 136. Single Number

    Given an array of integers, every element appears twice except for one. Find that single one. Note: ...

  8. as 打包报错

    错误:Android Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease' ...

  9. 深入浅出MS SQL——编辑table 出错

  10. 【推导】【线段树】hdu5929 Basic Data Structure

    题意: 维护一个栈,支持以下操作: 从当前栈顶加入一个0或者1: 从当前栈顶弹掉一个数: 将栈顶指针和栈底指针交换: 询问a[top] nand a[top-1] nand ... nand a[bo ...