原始碼編譯安裝mysql 5 7

2021-08-28 04:51:22 字數 3236 閱讀 6360

原始碼編譯安裝mysql 5.7.17

規劃:/mydata/data 資料目錄 (邏輯卷)

1、準備邏輯卷

2、解除安裝系統自帶的mariadb軟體

[root@mysqltest ~]# rpm -qa | grep mariadb

mariadb-libs-5.5.44-2.el7.centos.x86_64

[root@mysqltest ~]# rpm -e --nodeps mariadb-libs

3、修改資料目錄的所屬

[root@node02 ~]# useradd -s /sbin/nologin -m mysql

[root@node02 ~]# chown -r mysql.mysql /mydata/data/

4、安裝cmake編譯器 

[root@node02 ~]# yum install -y cmake

[root@node02 ~]# tar zxf mysql-boost-5.7.17.tar.gz 

[root@node02 ~]# cd mysql-5.7.17/

[root@mysql57 mysql-5.7.17]# cmake . \

-dcmake_install_prefix=/usr/local/mysql \

-dmysql_unix_addr=/tmp/mysql.sock \

-ddefault_charset=utf8 \

-ddefault_collation=utf8_general_ci \

-dmysql_datadir=/mydata/data \

-dmysql_tcp_port=3306 \

-dwith_boost=boost/boost_1_59_0/ \

-dwith_myisam_storage_engine=1 \

-dwith_innobase_storage_engine=1 \

-dwith_archive_storage_engine=1 \

-dwith_blackhole_storage_engine=1 \

錯誤1:

cmake error: your c compiler: "cmake_c_compiler-notfound" was not found.   please set cmake_c_compiler to a valid compiler path or name.

cmake error: your cxx compiler: "cmake_cxx_compiler-notfound" was not found.   please set cmake_cxx_compiler to a valid compiler path or name.

cmake error at cmake/os/linux.cmake:41 (message):

unsupported compiler!

call stack (most recent call first):

cmakelists.txt:162 (include)

解決辦法:

# yum groupinstall -y "development tools" "server platform development" "desktop platform development"

錯誤2:

解決辦法: 

[root@node02 ~]# yum install -y ncurses-devel.x86_64 

[root@mysqltest mysql-5.7.17]# make

[root@mysqltest mysql-5.7.17]# make install

[root@mysqltest ~]# chown -r root.mysql /usr/local/mysql/

初始化資料庫

[root@mysql57 ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/mydata/data

複製mysql配置檔案 

[root@node02 ~]# cd /usr/local/mysql/support-files/

[root@node02 support-files]# cp my-default.cnf /etc/my.cnf

[root@node02 support-files]# vim /etc/my.cnf

[mysqld]

...basedir=/usr/local/mysql

datadir=/mydata/data

port=3306

server_id=121

socket=/tmp/mysql.sock

如果啟動報錯 /tmp/mysql.sock.2型別錯誤,可以把/mydata/data資料目錄刪除以後重新初始化資料庫

啟動mysql服務 

[root@mysqltest data]# /usr/local/mysql/bin/mysqld_safe --user=mysql &

[root@mysqltest data]# ss -antp | grep mysqld

listen     0      80          :::3306                    :::*                   users:(("mysqld",pid=63756,fd=20))

[root@mysqltest data]# 

修改環境變數path

[root@mysqltest data]# cat /etc/profile.d/mysql.sh 

export path=$path:/usr/local/mysql/bin

[root@mysqltest data]# source /etc/profile.d/mysql.sh

[root@mysqltest data]# mysql -u root -p

mysql> alter user 'root'@'localhost' identified by 'www.1.com';

mysql> flush privileges;

query ok, 0 rows affected (0.00 sec)

設定原始碼mysql服務開機自啟動 

# vim /etc/rc.d/rc.local 

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

MySQL57原始碼編譯安裝

wgetwget安裝相關依賴 yum install y git cmake gcc gcc c bison ncurses ncurses devel bison devel libaio devel建立工作目錄和資料目錄 我的資料盤是掛在 opt下的 mkdir p opt mysql mkdi...

mysql5 7原始碼安裝

wget 2 將mysql安裝到 usr local mysql下 tar xvf mysql 5.7.22 linux glibc2.12 x86 64.tar.gz mv mysql 5.7.22 linux glibc2.12 x86 64 usr local mv usr local mys...

原始碼安裝MySQL 5 7

1 上傳安裝包wget2 新增系統mysql使用者和mysql組 useradd r g mysql mysql 新增mysql使用者 新增完成後可用id mysql檢視 groupadd mysql 新增mysql組3 解壓,把裡面裡面的東西放到 usr local mysql下 tar zxf ...