在日常运维的工作中,数据库的运维是必不可少的,从今天起未来一周都会专心总结mysql的应用。今天主要介绍mysql的安装,从源码包,和rpm包介绍。
源码包安装
可以去mysql官网下载源码包。
1 2 3 4 5 6 7 8 9
| [root@MySQL-Master src] [root@MySQL-Master src] [root@MySQL-Master mysql-5.1.63] --localstatedir=/data/mysql --enable-assembler \ --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static \ --with-pthread --enable-static --with-big-tables --without-ndb-debug \ --with-charset=utf8 --with-extra-charsets=all \ --without-debug --enable-thread-safe-client --enable-local-infile --with-plugins=max [root@MySQL-Master mysql-5.1.56]
|
安装参数介绍
–prefix=/usr/local/mysql //主程序安装目录
–localstatedir=/data/mysql //数据文件存放目录
–with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static//静态编译安装 mysql 客户端和服务端
–with-pthread //采用线程
–with-big-tables //对大表的支持
–with-charset=utf8 //默认字符集为 utf8
–with-extra-charsets=all //安装所有字符集
–without-debug //去掉 debug 模式
–enable-thread-safe-client //以线程方式编译客户端
–with-plugins=max //添加对 innodb 及 partition 的支持
–enable-local-infile //对 load data 的支持
创建用户和组
1 2
| [root@MySQL-Master mysql-5.1.56] [root@MySQL-Master mysql-5.1.56]
|
安装数据库
1 2 3 4
| [root@MySQL-Master mysql-5.1.56] [root@MySQL-Master mysql] [root@MySQL-Master mysql] --user=mysql
|
相应权限的修改
1 2
| [root@MySQL-Master mysql] [root@MySQL-Master mysql]
|
配置文件
1 2 3 4 5 6 7
| [root@MySQL-Master mysql] [root@MySQL-Master mysql] [root@MySQL-Master mysql] [root@MySQL-Master mysql] [root@MySQL-Master mysql] PATH=$PATH:$HOME/bin:/usr/local/mysql/bin [root@MySQL-Master mysql]
|
启动数据库并初始化密码。
1 2 3
| [root@MySQL-Master mysql] Starting MySQL [ OK ] [root@MySQL-Master mysql]
|
rpm安装mysql
安装mysql
1 2 3
| yum install mysql mysql-server chkconfig --levels 235 mysqld on //开机启动 /etc/init.d/mysqld start
|
注意:从centos7.0开始,yum软件库中不再有mysql-server,而是由mariaDB取代,mariaDB与mysql完全兼容。
在centos7.0中安装mysql,可以在MySQL Yum Repository找到yum安装源:
http://dev.mysql.com/downloads/repo/yum/
1 2 3
| wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm rpm -ivh mysql-community-release-el7-5.noarch.rpm yum install mysql-community-server
|