Mysql编译安装

413次阅读
没有评论

Mysql 编译安装

Mysql 的安装方式有三种,rpm 包安装,通用二进制安装,还有源码包安装,前两种安装都很简单,在生产环节中一般都是源码编译安装,所以今天就特地写了一篇不会的同学可以参考一下!

下载地址:点击下载

一、安装环境

Centos 6.5 系统

mysql-5.5    cmake 2.8

二、编译安装 Mysql

2.1、创建 mysql 用户安全启动 mysql

[root@www typ]# mkdir -p /mydata/data
[root@www typ]# groupadd -r mysql
[root@www typ]# useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql
[root@www typ]# chown -R mysql:mysql /mydata/data

2.2、安装 cmake

YUM 安装开发工具防止编译报错

yum -y install gcc gcc-c++ autoconf automake zlib* libxml2* ncurses ncurses-devel libtool-ltdl-devel* cmake

2.3、编译安装 mysql

[root@www typ]# tar xf mysql-5.5.8.tar.gz
[root@www typ]# cd mysql-5.5.8
[root@www mysql-5.5.8]# cmake . \
    -DCMAKE_INSTALL_PREFIX=/data/mysql\
    -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 \
    -DWITH_READLINE=1 \
    -DENABLED_LOCAL_INFILE=1 \
    -DEXTRA_CHARSETS=all \
    -DDEFAULT_CHARSET=utf8 \
    -DDEFAULT_COLLATION=utf8_general_ci
[root@www mysql-5.5.8]#make && make install

2.4、初始化 Mysql 数据库

[root@www mysql-5.5.8]# cd /data/mysql/
[root@www mysql-5.5.8]# chown  -R mysql.mysql .
[root@www mysql-5.5.8]# ./scripts/mysql_install_db –user=mysql –datadir=/mydata/data
Installing MySQL system tables…
OK
Filling help tables…
OK

2.5、配置 Mysql

[root@www mysql-5.5.8]# cp support-files/my-large.cnf /etc/my.cnf
# 在 /etc/my.cnf 文件中 [mysqld] 下添加如下行指定 mysql 数据文件的存放位置
datadir = /mydata/data

2.6、启动数据库

[root@www mysql-5.5.8]# cp support-files/mysql.server  /etc/init.d/mysqld
[root@www mysql-5.5.8]# chmod +x /etc/init.d/mysqld
[root@www mysql-5.5.8]# /etc/init.d/mysqld start

三、登陆 Mysql 数据库

echo “PATH=/data/mysql/bin:$PATH” >> /etc/profile

source /etc/profile

[root@www ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.8-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> show databases;
+——————–+
| Database           |
+——————–+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+——————–+
4 rows in set (0.00 sec)
mysql>

 

正文完
 
ddn
版权声明:本站原创文章,由 ddn 2015-12-23发表,共计2345字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。