码迷,mamicode.com
首页 > 数据库 > 详细

单实例MySQL安装

时间:2016-01-29 21:24:37      阅读:360      评论:0      收藏:0      [点我收藏+]

标签:mysql

1、建立账号

   [root@opsedu ~]# groupadd mysql

[root@opsedu ~]# useradd -s /sbin/nologin -g mysql -Mmysql

       useradd参数说明:

                -s/sbin/nologin 表示禁止该用户登录

                -gmysql 指定属于mysql

                -M表示不创建用户家目录

2、配置安装环境

    创建目录并授权:

   [root@opsedu ~]# mkdir /home/tools

[root@opsedu ~]# mkdir -p /usr/local/mysql

    [root@opsedu ~]#mkdir -p /data/mysql

    [root@opsedu ~]#chown -R mysql.mysql /usr/local/mysql/

    [root@opsedu ~]#chown -R mysql:mysql /data/mysql

    安装系统软件包:

[root@opsedu ~]# yum install gcc gcc-c++ make cmakencurses-devel bison perl

配置解析:

   [root@opsedu ~]# hostname

opsedu

[root@opsedu ~]# vim /etc/hosts

10.47.129.177 opsedu        添加一条

安装cmake

   [root@opsedu ~]# rpm -qa | grep cmake   使用系统自带cmake,编译时,有时候会报错

cmake-2.8.12.2-4.el6.x86_64         版本2.8.12

[root@opsedu ~]# yum remove cmake –y

[root@opsedu ~]# cd /home/tools

[root@opsedu tools]# wget https://cmake.org/files/v2.8/cmake-2.8.12.tar.gz

[root@opsedu tools]# tar -zxf cmake-2.8.12.tar.gz

[root@opsedu tools]# cd cmake-2.8.12

[root@opsedu cmake-2.8.12]# ./configure

    技术分享

[root@opsedu cmake-2.8.12]# gmake

[root@opsedu cmake-2.8.12]# gmake install

[root@opsedu cmake-2.8.12]# cd ..

[root@opsedu tools]# cmake --version

cmake version 2.8.12

3、安装mysql

[root@opsedu tools]# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.37.tar.gz

[root@opsedu tools]# tar -zxf mysql-5.5.37.tar.gz

[root@opsedu tools]# cd mysql-5.5.37

 

[root@opsedu mysql-5.5.37]# cmake \

> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \

> -DMYSQL_DATADIR=/data/mysql \

> -DMYSQL_TCP_PORT=3306 \

> -DDEFAULT_CHARSET=utf8 \

> -DDEFAULT_COLLATION=utf8_general_ci \

> -DEXTRA_CHARSETS=all \

> -DENABLED_LOCAL_INFILE=ON \

> -DWITH_INNOBASE_STORAGE_ENGINE=1 \

> -DWITH_FEDERATED_STORAGE_ENGINE=1 \

> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

> -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \

> -DWITHOUT_PARTITION_STORAGE_ENGINE=1 \

> -DWITH_FAST_MUTEXES=1 \

> -DWITH_ZLIB=bundled \

> -DENABLED_LOCAL_INFILE=1 \

> -DWITH_READLINE=1 \

> -DWITH_EMBEDDED_SERVER=1 \

> -DWITH_DEBUG=0 \

> -DMYSQL_UNIX_ADDR=/tmp/mysql.sock

    编译安装:

[root@opsedu mysql-5.5.37]# make

[root@opsedu mysql-5.5.37]# make install

    拷贝配置:

[root@opsedu mysql-5.5.37]# ll support-files/*.cnf

-rw-r--r-- 1 root root  4671 Jan 29 15:11 support-files/my-huge.cnf

-rw-r--r-- 1 root root 19759 Jan 29 15:11support-files/my-innodb-heavy-4G.cnf

-rw-r--r-- 1 root root  4645 Jan 29 15:11 support-files/my-large.cnf

-rw-r--r-- 1 root root  4656 Jan 29 15:11 support-files/my-medium.cnf

-rw-r--r-- 1 root root  2820 Jan 29 15:11 support-files/my-small.cnf

[root@opsedu mysql-5.5.37]# /bin/cpsupport-files/my-huge.cnf /etc/my.cnf

    创建mysql数据库文件:

[root@opsedu mysql-5.5.37]#/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql--datadir=/data/mysql --user=mysql

    启动mysql:

[root@opsedu mysql-5.5.37]#  /usr/local/mysql/bin/mysqld_safe --user=mysql&

[root@opsedu mysql-5.5.37]# netstat -lnt|grep 3306

tcp       0     0 0.0.0.0:3306          0.0.0.0:*               LISTEN

    配置mysql:

[root@opsedu ~]# echo ‘exportPATH=/usr/local/mysql/bin:$PATH‘ >>/etc/profile

[root@opsedu ~]# source /etc/profile

    配置mysql开机启动:

[root@opsedu mysql-5.5.37]# cpsupport-files/mysql.server /etc/init.d/mysqld

[root@opsedu mysql-5.5.37]# chmod 700 /etc/init.d/mysqld

[root@opsedu ~]# chkconfig --add mysqld

[root@opsedu ~]# chkconfig mysqld on

    mysql root用户增加密码:

[root@opsedu ~]# mysqladmin -uroot password‘q.123456‘

    安装之后的选项:

[root@opsedu ~]# mysql -uroot -pq.123456

mysql> select user,host,password from mysql.user;

+------+-----------+-------------------------------------------+

| user | host     | password                                 |

+------+-----------+-------------------------------------------+

| root | localhost |*026FC8CD6C3B58F3C3566D83F8189585C9F3F292 |

| root | opsedu   |                                           |

| root | 127.0.0.1 |                                           |

| root | ::1      |                                           |

|      |localhost |                                           |

|      |opsedu    |                                           |

+------+-----------+-------------------------------------------+

6 rows in set (0.00 sec)

    删除无用的账号:

mysql> delete from mysql.user where user=‘ ‘;

Query OK, 2 rows affected (0.00 sec)

 

mysql> delete from mysql.user where password=‘ ‘;

Query OK, 3 rows affected (0.00 sec)

 

mysql> select user,host,password from mysql.user;

+------+-----------+-------------------------------------------+

| user | host     | password                                  |

+------+-----------+-------------------------------------------+

| root | localhost |*026FC8CD6C3B58F3C3566D83F8189585C9F3F292 |

+------+-----------+-------------------------------------------+

1 row in set (0.00 sec)


本文出自 “Shaw Blog” 博客,请务必保留此出处http://opsedu.blog.51cto.com/9265055/1739876

单实例MySQL安装

标签:mysql

原文地址:http://opsedu.blog.51cto.com/9265055/1739876

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!