本文共 2026 字,大约阅读时间需要 6 分钟。
操作系统
more /etc/centos-release CentOS release 6.8 (Final)mysql5.6.44版本获取1:依赖包安装
yum list cmake yum install cmake -yyum install gcc-c++ -yyum install readline-devel pcre-devel ncurses-devel bison-devel -y2:创建目录安装,用户,获取安装包mkdir /home/setupcd /home/setupwget useradd mysql -s /sbin/nologin -Mtar -zxvf mysql-5.6.44.tar.gz3:编译安装cd /home/setup/mysql-5.6.44cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6 \
-DMYSQL_DATADIR=/data/3306/data \-DMYSQL_UNIX_ADDR=/data/3306/tmp/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \-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_EGINE=1 \-DWITH_FAST_MUTEXES=1 \-DWITH_ZLIB=bundled \-DENABLED_LOCAL_INFILE=1 \-DWITH_READLINE=1 \-DWITH_EMBEDDED_SERVER=1 \-DWITH_DEBUG=0#DCMAKE_INSTALL_PREFIX MySQL安装的根目录
#DMYSQL_DATADIR 数据存放的目录#DMYSQL_UNIX_ADDR MySQL的sock文件目录 mysql服务器用于监听的套接字,必需是绝对路径make && make install && cd ..
4:安装数据库
cd /application/mysql/scripts/./mysql_install_db --basedir=/application/mysql/ --datadir=/data/3306/data --user=mysql中途有2个ok表示安装成功mkdir /data/3306/tmp/
chown -R mysql.mysql /data/3306/tmp/cp /application/mysql/bin/* /usr/local/sbin/
cp /application/mysql/support-files/my-default.cnf /etc/my.cnf
vim /etc/my.cnf
[mysqld] 添加:
datadir=/data/3306/datadefault-storage-engine=InnoDBlower_case_table_names=1port=33065:启动数据库
cd /application/mysql/bin./mysqld_safe --defaults-file=/data/3306/data/my.cnf --user=mysql &登录数据库
mysql -uroot -S /data/3306/tmp/mysql.sock6:设置开机自启动
cp support-files/mysql.server /etc/init.d/mysql相关命令:
service mysql start 停止mysql服务 service mysql stop 重启mysql服务 service mysql restart 添加到开机启动项chkconfig --add mysql偶尔会遇到如下报错
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:解决方法yum-y install autoconf转载于:https://blog.51cto.com/9475587/2393336