yum -y
install
gcc gcc-c++ cmake bison
3.创建mysql组和用户
groupadd mysql
useradd
-g mysql mysql -s
/usr/sbin/nologin(不是登录用户)
4.解压mysql安装包
tar -zxvf 包名
5.编译安装
cmake
-DCMAKE_INSTALL_PREFIX=/opt/mysql
-DMYSQL_UNIX_ADDR=/opt/mysql/mysql.sock
-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_DATADIR=/opt/mysql/data
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306
make
&&
make
install
如果过程中出现-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) 这种错误,运行命令:
yum install ncurses-devel
6.编译参数说明:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安装目录 -DMYSQL_DATADIR=/usr/local/mysql/data //数据库存放目录 -DWITH_MYISAM_STORAGE_ENGINE=1 //安装myisam存储引擎 -DWITH_INNOBASE_STORAGE_ENGINE=1 //安装innodb存储引擎 -DWITH_ARCHIVE_STORAGE_ENGINE=1 //安装archive存储引擎 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 //安装blackhole存储引擎 -DENABLED_LOCAL_INFILE=1 //允许从本地导入数据 -DDEFAULT_CHARSET=utf8 //使用utf8字符 -DDEFAULT_COLLATION=utf8_general_ci //校验字符 -DEXTRA_CHARSETS=all //安装所有扩展字符集 -DMYSQL_TCP_PORT=3306 //MySQL监听端口 -DMYSQL_USER=mysql //MySQL用户名 -DWITH-EMBEDDED_SERVER=1 //编译成embedded MySQL library (libmysqld.a) -DSYSCONFDIR=/etc //MySQL配辑文件 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock //Unix socket 文件路径 -DWITH_READLINE=1 //快捷键功能 -DWITH_SSL=yes //SSL -DWITH_MEMORY_STORAGE_ENGINE=1 //安装memory存储引擎 -DWITH_FEDERATED_STORAGE_ENGINE=1 //安装frderated存储引擎 -DWITH_PARTITION_STORAGE_ENGINE=1 //安装数据库分区 -DINSTALL_PLUGINDIR=/usr/local/mysql/plugin //插件文件及配置路径7. 更改权限
chown
-R mysql:mysql 你的安装目录
8.复制配置文件
在安装目录下面新建conf文件:
mkdir conf
cp support-files/my-medium.cnf /conf/my.cnf
chmod
+x scripts
/mysql_install_db
./mysql_install_db --basedir=/opt/mysql/ --datadir=/opt/mysql/data/ --user=mysql
[mysqld] basedir = /opt/mysql datadir = /opt/mysql/data log-error = /opt/mysql/mysql_error.log pid-file = /opt/mysql/mysql.pid user = mysql tmpdir = /tmp
character_set_server = utf811. 启动mysql