一、数据库版本
- MysqL 常见版本
- MysqL Community Server 社区版本,开源免费,但不提供官方技术支持。
- MysqL Enterprise Edition 企业版本,需付费,可以试用 30 天。
- MysqL Cluster 集群版,开源免费。可将几个 MysqL Server 封装成一个 Server。
- MysqL Cluster CGE 高级集群版,需付费.
二、MysqL 安装部署
1、源码包编译安装
1)MysqL5.5版本及以后为了安全使用 cmake进行依赖检测,和额外配置,(在5.5版本之前使用 configure )常用选项。按需选择
cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/MysqL ----指定安装路径
-DMysqL_DATADIR=/data/MysqL ----MysqL 的数据文件路径
-DSYSCONFDIR=/etc ----配置文件路径
-DWITH_INNOBASE_STORAGE_ENGINE=1 ----使用 INNOBASE 存储引擎
-DWITH_MYISAM_STORAGE_ENGINE=1 ----安装 myisam 存储引擎
-DWITH_MEMORY_STORAGE_ENGINE=1 ----安装 memory 存储引擎
-DWITH_READLINE=1 ----支持批量导入 MysqL 数据
-DWITH_SSL=system ----MysqL 支持 ssl
-DWITH_ZLIB=system ----支持压缩存储
-DMysqL_TCP_PORT=3306 ----默认端口 3306
-DENABLED_LOCAL_INFILE=1 ----启用加载本地数据
-DMysqL_USER=MysqL ----指定 MysqL 运行用户
-DMysqL_UNIX_ADDR=/tmp/MysqL.sock ----默认套接字文件路径
-DEXTRA_CHARSETS=all ----是否支持额外的字符集
-DDEFAULT_CHARSET=utf8 ----默认编码机制
-DDEFAULT_COLLATION=utf8_general_ci ----默认字符校对
-DWITH_DEBUG=0 ----DEBUG 功能设置
2)5.5版本以前使用configure命令配置
./configure
--prefix=/usr/local/MysqL ----MysqL安装目录
--datadir=/data ----数据库存放目录
--with-charset=utf8 ----使用UTF8编码
--with-extra-charsets=complex ----安装所有的扩展字符集
--enable-thread-safe-client ----启用客户端安全线程
--with-big-tables ----启用大表
--with-ssl ----使用SSL加密
--enable-local-infile ----允许从本地导入数据
--enable-assembler ----汇编x86的普通操作符,可以提高性能
--with-plugins=innobase ----数据库插件,默认是none,innobase是数据库引擎,支持行级锁,及事务。
如果多个插件,可以写成:--with-plugins=partition,blackhole,heap,innobase,myisam,ndbcluster。
--with-plugins=partition ----分表功能,将一个大表分割成多个小表
3)编译安装
3.1、安装依赖库
yum -y install gcc gcc-c++ pcre-devel openssl openssl-devel zlib-devel ncurses-devel cmake bison libxml2-devel libpng-devel
3.2、下载源码包
wget -c https://cdn.MysqL.com//Downloads/MysqL-5.5/MysqL-5.5.62.tar.gz
useradd -r -s /sbin/nologin MysqL
3.4、编译安装
tar -zxvf MysqL-5.5.62.tar.gz
cd MysqL-5.5.62
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL \
-DMysqL_UNIX_ADDR=/tmp/MysqL.sock \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMysqL_USER=MysqL \
-DMysqL_TCP_PORT=3306
make
make install
cd /usr/local/MysqL
chown -R root .
chown -R MysqL data
cp -a /root/MysqL-5.5.62/support-files/my-medium.cnf /etc/my.cnf
3.7、初始化,生成授权表
cd /usr/local/MysqL #一定要先切换到此目录下,然后再执行下一步。
./scripts/MysqL_install_db --user=MysqL
cd /root/MysqL-5.5.62/support-files
cp -a MysqL.server /etc/init.d/MysqLd
chmod +x /etc/init.d/MysqLd
chkconfig --add MysqLd
# 让chkconfig 管理MysqLd命令,可以方便的设置开机自启
chkconfig MysqLd on
#开机自启
service MysqLd start|stop|restart
#添加到/etc/init.d/目录下的命令,可以通过service执行。
3.9、#创建root用户
/usr/local/MysqL/bin/MysqLadmin -uroot password 123456
3.10 登录
[root@centos ~]# /usr/local/MysqL/bin/MysqL -u root -p #如果为了使用命令方便,可以建立软连接。
Enter password:
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 2
Server version: 5.5.62-log Source distribution
Copyright (c) 2000,2018,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>
2、yum安装,有时候为了方便,我们使用yum安装
#安装
yum install MysqL-server MysqL -y
#启动MysqL服务,会自动进行初始化。
[root@centos ~]# service MysqLd start
#创建root用户
[root@centos ~]# MysqLadmin -uroot password 123456
#登录
[root@centos ~]# MysqL -uroot -p
Enter password:
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 3
Server version: 5.1.73 Source distribution
Copyright (c) 2000,2013,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>
#已经成功进入MysqL交互界面。