Home > Database > Mysql Tutorial > Centos6.7 编译安装 MySQL_MySQL

Centos6.7 编译安装 MySQL_MySQL

WBOY
Release: 2016-05-30 17:10:15
Original
1103 people have browsed it

# 安装依赖包
[root@localhost ~]# yum -y install gcc gcc-c++  autoconf* automake* zlib* libxml* ncurses-devel ncurses libgcrypt* libtool* cmake openssl openssl-devel bison bison-devel unzip wget

# 进入指定目录下载
[root@localhost ~]# cd /usr/local/src
[root@localhost ~]# wget http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.27.tar.gz

# 添加mysql运行账户
[root@localhost ~]# /usr/sbin/groupadd mysql
[root@localhost ~]# /usr/sbin/useradd mysql -g mysql -s /sbin/nologin -M

# 解压下载源码包
[root@localhost src]# tar zxvf mysql-5.6.27.tar.gz
[root@localhost src]# cd mysql-5.6.27

# 编译三步曲
[root@localhost mysql-5.6.27]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/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

[root@localhost mysql-5.6.27]# make && make install

# 复制mysql配置文件
[root@localhost mysql-5.6.27]# cp -rf support-files/my-default.cnf /etc/my.cnf

# 复制myssql启动管理文件
[root@localhost mysql-5.6.27]# cp support-files/mysql.server /etc/init.d/mysqld

# 赋权限
[root@localhost ~]# chmod 755 /etc/init.d/mysqld

# 添加开机启动
[root@localhost ~]# chkconfig --level 345 mysqld on

# 创建数据库存放目录
[root@localhost ~]# mkdir -p /data/mysql

# 给数据库目录权限赋给mysql用户
[root@localhost ~]# chown -R mysql:mysql /usr/local/mysql
[root@localhost ~]# chown -R mysql:mysql /data/mysql

[root@localhost ~]# cd /usr/local/mysql
[root@localhost ~]# ln -s /usr/local/mysql/bin/* /usr/sbin/

# 数据库初始化
[root@localhost ~]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --user=mysql --datadir=/data/mysql

# 启动数据库
[root@localhost ~]# /etc/init.d/mysqld start、

# 对数据账户进行基本安全设置
[root@localhost ~]# mysql_secure_installation
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template