centos7上源码安装mysql--运维高级

第一步,安装必要的依赖:

yum install -y cmake ncurses-devel  bison gcc gcc-c++ make unzip libaio numactl

 第二步,创建mysql用户和组:

wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18.tar.gz
tar zxvf mysql-5.7.18.tar.gz

第三步,下载MySQL 5.7.18 源码并解压:

wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18.tar.gz
tar zxvf mysql-5.7.18.tar.gz

第四步,编译安装:

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1
make
make install

第五步,配置MySQL: 

cd /usr/local/mysql/
mkdir mysql-files
chown mysql:mysql mysql-files 
chmod 750 mysql-files
bin/mysqld --initialize --user=mysql
bin/mysql_ssl_rsa_setup
chown -R root . 
chown -R mysql data

cp support-files/my-default.cnf /etc/my.cnf

bin/mysqld_safe --user=mysql &

 第六步,设置开机启动:

在/etc/rc.local中加入:

/usr/local/mysql/bin/mysqld_safe --user=mysql &

到此MySQL 5.7.18源码安装完成!可以设置root账号密码并连接测试。

pass:补充(报如下错误,我自己纠正了半天哈哈哈),教你怎么解决

这个错误表明 CMake 在配置 MySQL 时无法找到 Boost 库

CMake Error at cmake/boost.cmake:81 (MESSAGE):
  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=

  This CMake script will look for boost in .  If it is not there,
  it will download and unpack it (in that directory) for you.

  If you are inside a firewall, you may need to use an http proxy:

  export http_proxy=http://example.com:80

Call Stack (most recent call first):
  cmake/boost.cmake:238 (COULD_NOT_FIND_BOOST)
  CMakeLists.txt:460 (INCLUDE)


-- Configuring incomplete, errors occurred!
See also "/root/mysql-5.7.18/CMakeFiles/CMakeOutput.log".
See also "/root/mysql-5.7.18/CMakeFiles/CMakeError.log".
[root@localhost mysql-5.7.18]# 

解决步骤:

 第一步:删除之前缓存

rm -rf build
mkdir build
cd build

使用 CMake 时,指定 Boost 的位置,例如:

cmake -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/path/to/boost ..

请将 /path/to/boost 替换为你系统中 Boost 库的实际路径。

如果你不想手动指定 Boost,可以尝试让 CMake 下载并自动配置 Boost,使用以下命令:

cmake -DDOWNLOAD_BOOST=1 ..

回去重新make吧就基本没啥错误了,只要你是跟着我一步一步来的!!!!

你可能感兴趣的:(运维高级-从菜鸟到大牛,mysql,运维,adb)