首页 > 代码库 > Linux中MySQLl单实例源码编译安装

Linux中MySQLl单实例源码编译安装

MySQL5.5以后源码安装要用cmake

1.3 安装相关包(cmake)
  1.3.1 cmake软件
   cd /home/Public/tools/
   tar xf cmake-2.8.8.tar.gz
   cd cmake-2.8.8
   ./configure
  #CMake has bootstrapped. Now run gmake.
  gmake
  gmake install
  cd ../

  1.3.2 依赖包
  yum install ncurses-devel -y

1.4 开始安装mysql
  1.4.1 创建用户和组
  groupadd mysql
  useradd mysql -s /sbin/nologin -M -g mysql

  1.4.2 解压编译MySQL
  tar zxf mysql-5.5.32.tar.gz
  cd mysql-5.5.32
  cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.34 \
  -DMYSQL_DATADIR=/usr/local/mysql-5.6.34/data \
  -DMYSQL_UNIX_ADDR=/usr/local/mysql-5.6.34/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 \
  -DWITH_FAST_MUTEXES=1 \
  -DWITH_ZLIB=bundled \
  -DENABLED_LOCAL_INFILE=1 \
  -DWITH_READLINE=1 \
  -DWITH_EMBEDDED_SERVER=1 \
  -DWITH_SSL=bundled \
  -DWITH_DEBUG=0


  make失败时候:make clean rm -f CMakeCache.txt
  #-- Build files have been written to: /home/oldboy/tools/mysql-5.5.32
  提示,编译时可配置的选项很多,具体可参考结尾附录或官方文档:
  make
  #[100%] Built target my_safe_process
  make install
  ln -s /application/mysql-5.5.32/ /application/mysql
  如果上述操作未出现错误,则MySQL5.5.32软件cmake方式的安装就算成功了。

  cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
  写到配置文件 echo ‘export PATH=/usr/local/mysql/bin:$PATH‘ >> /etc/profile
  source /etc/profile
  echo $PATH
  授权 chown -R mysql:mysql /usr/local/mysql/data/
  初始化
  /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql
  cp /home/centos3/Public/apps/mysql-5.6.34/support-files/mysql.server /etc/init.d/mysqld
  增加密码: /usr/local/mysql//bin/mysqladmin -u root password ‘new-password‘ 

Linux中MySQLl单实例源码编译安装