centos7.2環境編譯安裝mysql5.5.48 [轉 ]

來源:互聯網
上載者:User

標籤:groupadd   /tmp   sele   fir   pac   require   occurred   開機   ext4   

一.安裝cmake編譯工具

跨平台編譯器
查看是否已經安裝了gcc

# rpm -qa | grep gcc

# yum install -y gcc-c++
# yum install -y cmake
# yum install -y git
解決依賴關係
# yum install -y readline-devel zlib-devel openssl-devel

Warning: Bison executable not found in PATH
 
解決方案:
#  yum install -y bison
再次編譯即通過

二、編譯安裝mysql-5.5.48


# tar xf mysql-5.5.48.tar.gz
# cd mysql-5.5.48
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mydata -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

 

 # make && make install

編譯報錯需要刪除編譯緩衝
rm CMakeCache.txt

編譯報錯:

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Looking for getpagesize - not found
-- Looking for TIOCGWINSZ
CMake Error at /usr/share/cmake/Modules/CMakeCInformation.cmake:37 (get_filename_component):
  get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
  CMakeLists.txt:3 (PROJECT)

安裝gcc-c++即可

 

cmake . -- Running cmake version 2.8.10.2 -- Could NOT find Git (missing: GIT_EXECUTABLE) -- Configuring with MAX_INDEXES = 64U -- Looking for SHM_HUGETLB -- Looking for SHM_HUGETLB - found -- Looking for sys/types.h -- Looking for sys/types.h - found -- Looking for stdint.h -- Looking for stdint.h - found -- Looking for stddef.h -- Looking for stddef.h - found -- Check size of void * -- Check size of void * - done -- SIZEOF_VOIDP 8 -- MySQL 5.7.9 -- Packaging as: mysql-5.7.9-Linux-x86_64 -- Looked for boost/version.hpp in and -- BOOST_INCLUDE_DIR BOOST_INCLUDE_DIR-NOTFOUND -- LOCAL_BOOST_DIR -- LOCAL_BOOST_ZIP -- Could not find (the correct version of) boost. -- MySQL currently requires boost_1_59_0 CMake Error at cmake/boost.cmake:76 (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:228 (COULD_NOT_FIND_BOOST) CMakeLists.txt:435 (INCLUDE) -- Configuring incomplete, errors occurred!

安裝git即可

三、建立存放Mysql資料庫檔案的邏輯卷並掛載到/data/mydata下

分區
# fdisk /dev/sda
n
p
3
+20G
w

#掛載系統磁碟分割
# kpartx -l /dev/sda
# kpartx -af /dev/sda
# partx -a /dev/sda
驗證是否掛載成功
# cat /proc/partitions
建立物理卷
# pvcreate /dev/sda3
建立名為myvg的卷組
# vgcreate myvg /dev/sda3
#建立一個大小為15G,名字叫做mylv的邏輯卷
# lvcreate -L 15G -n mylv myvg
格式化
# mke2fs -t ext4 -b 2048 /dev/myvg/mylv

# mkdir -pv /data/mydata
mkdir: created directory ‘/data’
mkdir: created directory ‘/data/mydata’
# mount /dev/myvg/mylv /data/mydata
# vim /etc/fstab
添加如下內容:
/dev/myvg/mylv /data/mydataext4defaults,noatime 0 0

四、建立Mysql使用者

添加mysql使用者指定組id和使用者id為306
# groupadd -r -g 306 mysql
# useradd -g mysql -r -g 306 -s /sbin/nologin mysql
# id mysql
uid=994(mysql) gid=306(mysql) groups=306(mysql)


改變資料存放區目錄和安裝目錄的許可權
# cd /usr/local/mysql
添加存放日誌的目錄
# mkdir /data/binlogs
# chown -R :mysql ./*
# chown -R mysql.mysql /data/mydata

五、啟動指令碼初始化資料庫

# scripts/mysql_install_db --user=mysql --datadir=/data/mydata
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# cp support-files/my-large.cnf /etc/my.cnf


編輯/etc/my.cnf配置,加入以下內容

innodb_file_per_table = ON

datadir = /data/mydata

log-bin=/data/binlogs/mysql-bin

注意:

經過實際測試innodb_file_per_table = ON這條參數需要innodb_file_per_table = 1 才會生效,具體可以通過

mysql> show variables like ‘%per_table%‘;來查詢

把mysqld服務加入到啟動項
# chkconfig --add mysqld
# chkconfig --list mysqld


將mysql命令加入環境變數中
vim /etc/profile.d/mysql.sh
加入
export PATH=/usr/local/mysql/bin:$PATH


啟動mysqld服務
# service mysqld start
報錯
Starting MySQL. ERROR! The server quit without updating PID file (/data/mydata/oadb-test.pid).
# ss -tnl

可以觀察日誌/data/mydata/oadb-test.err,是日誌建立許可權的問題
# chown -R mysql.mysql /data

六、上傳通達OA資料庫並配置相關許可權

上傳通達OA資料庫到伺服器上,修改許可權,並重啟服務,測試


# chown -R mysql.mysql /data/mydata
# service mysqld restart

對mysql資料庫使用者進行清理,加密碼

mysql> use mysqlDatabase changedmysql> select user,host,password from user;+------+-----------+----------+| user | host      | password |+------+-----------+----------+| root | localhost |          || root | adb-test  |          || root | 127.0.0.1 |          || root | ::1       |          ||      | localhost |          ||      | adb-test  |          |+------+-----------+----------+6 rows in set (0.01 sec)mysql> delete from user where user=‘‘ and host=‘localhost‘;Query OK, 1 row affected (0.01 sec)mysql> delete from user where user=‘‘ and host=‘adb-test‘;Query OK, 1 row affected (0.00 sec)


設定其中root密碼為myoa888,並對伺服器IP限制
mysql> update user set password=PASSWORD(‘myoa888‘),host=‘192.168.11.144‘ where user=‘root‘ and host=‘::1‘;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

對root使用者加密

mysql> update user set password=PASSWORD(‘13C1325E831DEC8D60‘) where user=‘root‘ and host in(‘localhost‘,‘adb-test‘,‘127.0.0.1‘);mysql> select user,host,password from user;+------+----------------+-------------------------------------------+| user | host           | password                                  |+------+----------------+-------------------------------------------+| root | localhost      | *CF51F9E245F41378E51B4154082F26108A5B0D63 || root | adb-test       | *CF51F9E245F41378E51B4154082F26108A5B0D63 || root | 127.0.0.1      | *CF51F9E245F41378E51B4154082F26108A5B0D63 || root | 192.168.11.144 | *91AF99F23C3D4ED85140D100433725DFA52BECEE |+------+----------------+-------------------------------------------+

centos7關閉防火牆命令
# systemctl stop firewalld.service

systemctl start firewalld.service#啟動firewall
systemctl disable firewalld.service#禁止firewall開機啟動

 

centos7.2環境編譯安裝mysql5.5.48 [轉 ]

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.