虚拟化容器,大数据,DBA,中间件,监控。

RedFlag LinuxSP3 编译最新版mysql 5.6.14

24 10月
作者:admin|分类:DBA运维



下载好最新版mysql-5.6.14.tar.gz


首先 建好mysql用户与用户组,


#:groupadd -g 45 mysql && useradd -c "MySQL Server" -d /srv/mysql -g mysql -s /bin/false -u 45 mysql


解压mysql,进入mysql目录。

#:make . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/usr/local/mysql/data
-DSYSCONFDIR=/etc
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock
-DENABLED_LOCAL_INFILE=1
-DEXTRA_CHARSETS=all -DMYSQL_USER=mysql


或是用以下方法,会有报错。

#:sed -i "/ADD_SUBDIRECTORY(sql\/share)/d" CMakeLists.txt &&
sed -i "s/ADD_SUBDIRECTORY(libmysql)/&\\nADD_SUBDIRECTORY(sql\/share)/" CMakeLists.txt &&
sed -i "s@data/test@\${INSTALL_MYSQLSHAREDIR}@g" sql/CMakeLists.txt &&
sed -i "s@data/mysql@\${INSTALL_MYSQLTESTDIR}@g" sql/CMakeLists.txt &&

sed -i "s/srv_buf_size/srv_sort_buf_size/" storage/innobase/row/row0log.cc &&

mkdir build &&
cd build &&

cmake -DCMAKE_BUILD_TYPE=Release                    \
      -DCMAKE_INSTALL_PREFIX=/usr                   \
      -DINSTALL_DOCDIR=share/doc/mysql              \
      -DINSTALL_DOCREADMEDIR=share/doc/mysql        \
      -DINSTALL_INCLUDEDIR=include/mysql            \
      -DINSTALL_INFODIR=share/info                  \
      -DINSTALL_MANDIR=share/man                    \
      -DINSTALL_MYSQLDATADIR=/srv/mysql             \
      -DINSTALL_MYSQLSHAREDIR=share/mysql           \
      -DINSTALL_MYSQLTESTDIR=share/mysql/test       \
      -DINSTALL_PLUGINDIR=lib/mysql/plugin          \
      -DINSTALL_SBINDIR=sbin                        \
      -DINSTALL_SCRIPTDIR=bin                       \
      -DINSTALL_SQLBENCHDIR=share/mysql/bench       \
      -DINSTALL_SUPPORTFILESDIR=share/mysql         \
      -DMYSQL_DATADIR=/srv/mysql                    \
      -DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock     \
      -DSYSCONFDIR=/etc/mysql                       \
      -DWITH_PERFSCHEMA_STORAGE_ENGINE=OFF          \
      -DWITH_EXTRA_CHARSETS=complex                 \
      -DWITH_LIBEVENT=system                        \
      -DWITH_SSL=system                             \
      -DWITH_SSL=bundled                            \   
      -DENABLE_DOWNLOADS=1                          \
      .. &&
make




进入安装目录,初始化数据库
#:cd /usr/local/mysql/
 
#:cd scripts/
#:./mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local//mysql/data --user=mysql


复制开机启动脚本
#:cp mysql.server /etc/init.d/mysqld

修改脚本以下内容

basedir=/usr/local/mysql
datadir=/usr/local//mysql/data

加入启动项:
#chkconfig --add mysqld
#chkconfig --level 345 mysqld on 

复制配置文件my.cnf

#:cp ../support-files/my-default.cnf /etc/my.cnf
配置My.cnf

#:echo "" > /etc/my.cnf

加入以下内容:


[client]
port            = 3306
socket          = /tmp/mysql.sock
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 128M
max_allowed_packet = 128M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 2M
myisam_sort_buffer_size = 8M
thread_cache_size = 8
query_cache_size= 16M
thread_concurrency = 8
max_connections = 300
wait_timeout = 30
interactive_timeout = 30
max_connect_errors = 9
long_query_time = 1
tmp_table_size = 16M
#log-bin=mysql-bin
#binlog_format=mixed
#server-id      = 1
[mysqldump]
quick
max_allowed_packet = 8M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 12M
sort_buffer_size = 1M
read_buffer = 1M
write_buffer = 1M
[mysqlhotcopy]
interactive-timeout



配置数据库密码
/usr/local/mysql/bin/mysqladmin -u root password ''

这里设置空密码。

然后启动数据库。

#:service mysqld start

测试数据库登陆。




在安装时configure会报以后错.

Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Googlemock was not found. gtest-based unit tests will be disabled.
You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://foo.bar.com:80
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- Configuring done


在使用cmake时,要加入以下参数。

cmake . -DENABLE_DOWNLOADS=1

还要安装以下安装包。


    yum install -y ncurses-devel.x86_64
    yum install -y cmake.x86_64
    yum install -y libaio.x86_64
    yum install -y bison.x86_64







浏览2845 评论0
返回
目录
返回
首页
mysql5.6源代码编译安装 OpenSSL-1.0.1e 编译安装最新版