mysql5.6編譯安裝(cmake方式)

一、 安裝cmakemysql

# tar xzvf cmake-2.8.8.tar.gzsql

# cd cmake-2.8.8數據庫

# ./configure安全

# gmakeapp

# gmake installdom

二、 安裝ncurses-develsocket

三、 安裝mysql優化

3.1)建立用戶及組ui

# groupadd mysqlspa

# useradd -r -g mysql -s /bin/false mysql

3.2)解壓安裝包,cmake安裝

# tar xzvf mysql-5.6.37.tar.gz

#cd mysql-5.6.37

# cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.37 \

-DMYSQL_DATADIR=/application/mysql-5.6.37/data \

-DMYSQL_UNIX_ADDR=/application/mysql-5.6.37/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 \

-DWITHOUT_PARTITION_STORAGE_ENGINE=0 \

-DWITH_FAST_MUTEXES=1 \

-DWITH_ZLIB=bundled \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_READLINE=1 \

-DWITH_EMBEDDED_SERVER=1 \

-DWITH_DEBUG=0

#make && make install 

說明:若是cmake出錯,須要執行make clean; rm -f CMakeCache.txt

 四、配置系統環境變量:

export PATH=/application/mysql/bin:/application/mysql/scripts:$PATH將這行內容追加到/etc/profile文件結尾。

五、拷貝配置文件:

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

六、初始化數據庫:

# mysql_install_db --user=mysql --basedir=/application/mysql-5.6.37 --datadir=/application/mysql-5.6.37/data

七、啓動數據庫:

# cp support-files/mysql.server /etc/init.d/mysqld

# chmod +x /etc/init.d/mysqld

# chown -R mysql:mysql application/

#mkdir /application/mysql-5.6.37/tmp

# chmod -R 1777 tmp

注意:安裝過程當中的報錯

Linking CXX executable pfs_connect_attr-t

../../../sql/libsql.a(handler.cc.o): In function `get_ha_partition(partition_info*)':

/root/mysql-5.6.37/sql/handler.cc:460: undefined reference to `ha_partition::ha_partition(handlerton*, partition_info*)'

/root/mysql-5.6.37/sql/handler.cc:462: undefined reference to `ha_partition::initialize_partition(st_mem_root*)'

../../../sql/libsql.a(sql_partition_admin.cc.o): In function `Sql_cmd_alter_table_truncate_partition::execute(THD*)':

/root/mysql-5.6.37/sql/sql_partition_admin.cc:822: undefined reference to `ha_partition::truncate_partition(Alter_info*, bool*)'

collect2: ld returned 1 exit status

make[2]: *** [storage/perfschema/unittest/pfs_connect_attr-t] Error 1

make[1]: *** [storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/all] Error 2

make: *** [all] Error 2

 

緣由:-DWITHOUT_PARTITION_STORAGE_ENGINE=1

解決方法:-DWITHOUT_PARTITION_STORAGE_ENGINE=0

 

[root@localhost mysql-5.6.37]# /etc/init.d/mysqld start

Starting MySQL.Logging to '/application/mysql-5.6.37/data/localhost.localdomain.err'.

171028 15:38:23 mysqld_safe Directory '/application/mysql-5.6.37/tmp' for UNIX socket file don't exists.

The server quit without updating PID file (/application/mysql-5.6.37/data/localhost.localdomain.pid).[FAILED]

 

解決方法:修改mysql安裝目錄權限爲mysql

#mkdir /application/mysql-5.6.37/tmp

# chmod -R 777 tmp

 

八、 mysql初始安全優化

5.1)刪除test數據庫

5.2)刪除無用的用戶,如mysql.user表中的一些無用用戶。

相關文章
相關標籤/搜索