# 请在之前的文章.参照操作系统安装方法. # 安装方法不同,可能会导致无法成功编译安装mysql.
# 编译安装的方法 # 使用yum安装bison yum install bison
# 下载地址 # mysql 下载地址 官网的列表 需要自己去选择 # http://dev.mysql.com/downloads/mirrors.html
# cmake 下载地址 官网的列表 需要自己去选择 # http://www.cmake.org/cmake/resources/software.html
# 下载mysql 和 cmake wget ftp://ftp.cs.pu.edu.tw/Unix/mysq ... mysql-5.5.18.tar.gz
wget http://www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz
# 解压 tar zxf cmake-2.8.6.tar.gz
tar zxf mysql-5.5.18.tar.gz
# 进入cmake 目录 cd cmake-2.8.6
# 编译 安装 ./configure && make && make install cd ../
# 进入mysql 目录 cd mysql-5.5.18
# 使用 cmake 编译 cmake \
-DCMAKE_INSTALL_PREFIX=/soft/mysql-5.5.18 \
-DMYSQL_DATADIR=/data/mysql-5.5.18/ \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_EXTRA_CHARSETS=complex \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_unicode_ci \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1
# 编译 安装 make && make install
# 建立mysql组
/usr/sbin/groupadd mysql
# 建立mysql用户并加入到mysql组
/usr/sbin/useradd -g mysql mysql -s /sbin/nologin
# 建立数据路径 mkdir -p /data/mysql-5.5.18/
# 修改目录权限 chown -R mysql:mysql /data/mysql-5.5.18
# 复制配置文件到/etc目录 cp support-files/my-medium.cnf /etc/my.cnf
# 复制服务文件到 /etc/init.d目录
cp support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld
# 增加mysql 路径到 /etc/profile 目录 (功能是增加环境变量) echo "PATH=\$PATH:/data/soft/mysql-5.5.18/bin" >> /etc/profile
# 重读 profile 让环境变量立刻生效 . /etc/profile
# 初始化数据库 /data/soft/mysql-5.5.18/scripts/mysql_install_db --user=mysql --basedir=/data/soft/mysql-5.5.18/ --datadir=/data/mysql-5.5.18/
# 开启mysql service mysqld start
# 清理MYSQL默认数据
mysql -uroot -e "drop database test;"
# 清除主机名
mysql -uroot -e "DELETE FROM mysql.user WHERE Host='$HOSTNAME';"
# 清除主机默认IP地址
mysql -uroot -e "DELETE FROM mysql.user WHERE Host='127.0.0.1';"
# 清除权限
mysql -uroot -e "DELETE FROM mysql.user WHERE Host='localhost' and User='';"
# 修改mysql root 密码为 123456 mysqladmin -u root -p password '123456'
# 将mysql 加入服务 chkconfig --add mysqld
# 设置启动 chkconfig mysqld on
# 重启mysql service mysqld restart
--------------------------------------以下为说明和一些介绍--------------------------------- ---------------------1 TYPE=MyISAM 与ENGINE=MyISAM 的区别 TYPE=MyISAM 和 ENGINE=MyISAM 都是设置数据库存储引擎的语句 (老版本的MySQL使用TYPE而不是ENGINE(例如,TYPE = MYISAM)。
MySQL 5.1为向下兼容而支持这个语法,但TYPE现在被轻视,而ENGINE是首先的用法。
一般地,ENGINE 选项是不必要的;除非默认已经被改变了,MyISAM是默认存储引擎。
如果使用Navicat 要使用高版本
如果Navicat< 8.0 建立表可能会报错
---------------------2 该版本一个最大的改动就是增加了性能的元数据信息库,数据库名为 performance_schema ,采用的存储引擎是 PERFORMANCE_SCHEMA,该数据库将会记录数据库性能相关的一些数据信息。关于 performance_schema 的更多信息请看 Chapter 20, MySQL Performance Schema。另外该数据库并不是默认启用的,需要在启动服务的时候指定 --performance_schema 参数。
mysql 5.5 新特性及修改内容 http://dev.mysql.com/doc/refman/5.5/en/mysql-nutshell.html ---------------------3 如果不单独的加入 表引擎选项 默认情况
| CSV | YES | CSV storage engine | NO | NO | NO | | InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES | | PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO | | MyISAM | YES | MyISAM storage engine | NO | NO | NO | | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO | | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
编译加入了 -DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| CSV | YES | CSV storage engine | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
---------------------4 -- 打开sql执行记录功能
set global log_output='TABLE'; -- 输出到表
set global log=ON; -- 打开所有命令执行记录功能general_log, 所有语句: 成功和未成功的.
set global log_slow_queries=ON; -- 打开慢查询sql记录slow_log, 执行成功的: 慢查询语句和未使用索引的语句
set global long_query_time=0.1; -- 慢查询时间限制(秒)
set global log_queries_not_using_indexes=ON; -- 记录未使用索引的sql语句
-- 查询sql执行记录
select * from mysql.slow_log order by 1; -- 执行成功的:慢查询语句,和未使用索引的语句
select * from mysql.general_log order by 1; -- 所有语句: 成功和未成功的.
-- 关闭sql执行记录
set global log=OFF;
set global log_slow_queries=OFF;
-- long_query_time参数说明
-- v4.0, 4.1, 5.0, v5.1 到 5.1.20(包括):不支持毫秒级别的慢查询分析(支持精度为1-10秒);
-- 5.1.21及以后版本 :支持毫秒级别的慢查询分析, 如0.1;
-- 6.0 到 6.0.3: 不支持毫秒级别的慢查询分析(支持精度为1-10秒);
-- 6.0.4及以后:支持毫秒级别的慢查询分析;
---------------------5cmake 和 configure的对比
configure Command | CMake Command | ./configure | cmake . | ./configure --help | cmake . -LH or ccmake . |
安装选项 Parameter | configure Option | CMake Option | CMake Notes | Installation base directory | --prefix=/usr | -DCMAKE_INSTALL_PREFIX=/usr |
| mysqld directory | --libexecdir=/usr/sbin | -DINSTALL_SBINDIR=sbin | interpreted relative to prefix | Data directory | --localstatedir=/var/lib/mysql | -DMYSQL_DATADIR=/var/lib/mysql |
| Config directory (for my.cnf) | --sysconfdir=/etc/mysql | -DSYSCONFDIR=/etc/mysql |
| Plugin directory | --with-plugindir=/usr/lib64/mysql/plugin | -DINSTALL_PLUGINDIR=lib64/mysql/plugin | interpreted relative to prefix | Man page directory | --mandir=/usr/share/man | -DINSTALL_MANDIR=share/man | interpreted relative to prefix | Shared-data directory | --sharedstatedir=/usr/share/mysql | -DINSTALL_SHAREDIR=share | this is where aclocal/mysql.m4 should be installed | Library installation directory | --libdir=/usr/lib64/mysql | -DINSTALL_LIBDIR=lib64/mysql | interpreted relative to prefix | Header installation directory | --includedir=/usr/include/mysql | -DINSTALL_INCLUDEDIR=include/mysql | interpreted relative to prefix | Info doc directory | --infodir=/usr/share/info | -DINSTALL_INFODIR=share/info | interpreted relative to prefix |
存储引擎选项 注:mysql 5.5.x 中InnoDB作为默认的数据库存储引擎举例如下 开启 该数据引擎 -DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_BLACKHOE_STORAGE_ENGINE=1关闭 该数据引擎-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1-DWITHOUT_FEDERATED_STORAGE_ENGINE=1-DWITHOUT_PARTITION_STORAGE_ENGINE=1
lib选项
Parameter | configure Option | CMake Option | CMake Notes | readline library | --with-readline | -DWITH_READLINE=1 |
| SSL library | --with-ssl=/usr | -DWITH_SSL=system |
| zlib library | --with-zlib-dir=/usr | -DWITH_ZLIB=system |
| libwrap library | --without-libwrap | -DWITH_LIBWRAP=0 |
|
其他选项
Parameter | configure Option | CMake Option | CMake Notes | TCP/IP port number | --with-tcp-port-=3306 | -DMYSQL_TCP_PORT=3306 |
| UNIX socket file | --with-unix-socket-path=/tmp/mysqld.sock | -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock |
| Enable LOCAL for LOAD DATA | --enable-local-infile | -DENABLED_LOCAL_INFILE=1 |
| Extra charsets | --with-extra-charsets=all | -DEXTRA_CHARSETS=all | default is "all" | Default charset | --with-charset=utf8 | -DDEFAULT_CHARSET=utf8 |
| Default collation | --with-collation=utf8_general_ci | -DDEFAULT_COLLATION=utf8_general_ci |
| Build the server | --with-server | none |
| Build the embedded server | --with-embedded-server | -DWITH_EMBEDDED_SERVER=1 |
| libmysqld privilege control | --with-embedded-privilege-control | none | always enabled? | Install the documentation | --without-docs | none |
| Big tables | --with-big-tables, --without-big-tables | none | tables are big by default | mysqld user | --with-mysqld-user=mysql | -DMYSQL_USER=mysql | mysql is the default | Debugging | --without-debug | -DWITH_DEBUG=0 | default is debugging disabled | GIS support | --with-geometry | none | always enabled? | Community features | --enable-community-features | none | always enabled | Profiling | --disable-profiling | -DENABLE_PROFILING=0 | enabled by default | pstack | --without-pstack | none | pstack is removed | Assembler string functions | --enable-assembler | none |
| Build type | --build=x86_64-pc-linux-gnu | no equivalent | unneeded? | Cross-compile host | --host=x86_64-pc-linux-gnu | no equivalent | unneeded? | Client flag | --with-client-ldflags=-lstdc++ | none | unneeded | Client flag | --enable-thread-safe-client | none | unneeded, clients are always thread safe | Comment | --with-comment='string' | -DWITH_COMMENT='string' |
| Shared/static binaries | --enable-shared --enable-static | none | there is only DISABLE_SHARED | Memory use | --with-low-memory | none | unneeded |
cmake 日志存放位置 CMakeFiles/CMakeError.log CMakeFiles/CMakeOutput.log
清理编译参数make clean rm CMakeCache.txt
附件为mysql5.5新特性(中文的).
|