linux下使用cmake編譯安裝mysql的詳細(xì)教程
一、安裝cmake
1、解壓cmake壓縮包
[root@mysql tools]# tar -zvxf cmake-2.8.8.tar.gz [root@mysql tools]# ls cmake-2.8.8 cmake-2.8.8.tar.gz mysql-5.5.16.tar.gz scripts
2、解析
[root@mysql tools]# cd cmake-2.8.8 [root@mysql cmake-2.8.8]# ./configure --------------------------------------------- CMake 2.8.8, Copyright 2000-2009 Kitware, Inc. Found GNU toolchain C compiler on this system is: gcc C++ compiler on this system is: g++ Makefile processor on this system is: gmake g++ is GNU compiler g++ has STL in std:: namespace g++ has ANSI streams g++ has streams in std:: namespace
3、安裝
[root@mysql cmake-2.8.8]# echo $? 0 #如果返回值是0,就是執(zhí)行成功,如果返回值是1,就是執(zhí)行失敗; [root@mysql cmake-2.8.8]# gmake && gmake install Scanning dependencies of target cmIML_test [ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test.c.o [ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_ABI_C.c.o [ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_INT_C.c.o [ 1%] Building C object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_include_C.c.o [ 2%] Building CXX object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_ABI_CXX.cxx.o [ 2%] Building CXX object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_INT_CXX.cxx.o [ 2%] Building CXX object Utilities/KWIML/test/CMakeFiles/cmIML_test.dir/test_include_CXX.cxx.o
二、開始安裝mysql
1、首先需要安裝(ncurses-devel)依賴包
[root@mysql cmake-2.8.8]# cd … [root@mysql tools]# yum -y install ncurses-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile base: mirrors.zju.edu.cn extras: centos.ustc.edu.cn updates: mirrors.zju.edu.cn Resolving Dependencies –> Running transaction check —> tools ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 will be installed #############安裝完成后檢查########### [root@mysql tools]# rpm -qa | grep ncurses-devel ncurses-devel-5.9-14.20130511.el7_4.x86_64 [root@mysql tools]#
2、解壓mysql壓縮包
[root@mysql tools]# tar -zvxf mysql-5.5.16.tar.gz [root@mysql tools]# ls cmake-2.8.8 cmake-2.8.8.tar.gz mysql-5.5.16 mysql-5.5.16.tar.gz scripts [root@mysql tools]#
3、創(chuàng)建虛擬用戶
[root@mysql tools]# useradd mysql -s /sbin/nologin -M [root@mysql tools]# id mysql uid=1000(mysql) gid=1000(mysql) groups=1000(mysql) [root@mysql tools]#
4、配置解析
[root@mysql tools]# cd mysql-5.5.16 [root@mysql mysql-5.5.16]# [root@mysql mysql-5.5.16]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.16 -DMYSQL_DATADIR=/usr/local/mysql-5.5.16/data -DMYSQL_UNIX_ADDR=/usr/local/mysql-5.5.16/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=1 -DWITH_FAST_MUTEXES=1 -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DWITH_DEBUG=0
5、安裝
[root@mysql mysql-5.5.16]# make && make install Scanning dependencies of target INFO_BIN [ 0%] Built target INFO_BIN Scanning dependencies of target INFO_SRC [ 0%] Built target INFO_SRC Scanning dependencies of target abi_check [ 0%] Built target abi_check Scanning dependencies of target zlib
6、創(chuàng)建軟連接
[root@mysql mysql-5.5.16]# ln -s /usr/local/mysql-5.5.16/ /usr/local/mysql [root@mysql mysql-5.5.16]# readlink /usr/local/mysql /usr/local/mysql-5.5.16/ [root@mysql mysql-5.5.16]#
7、配置環(huán)境
[root@mysql mysql-5.5.16]# cd … [root@mysql tools]# echo ‘export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile [root@mysql tools]# tail -1 /etc/profile export PATH=/usr/local/mysql/bin:$PATH [root@mysql tools]# source /etc/profile [root@mysql tools]# echo $PATH /usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@mysql tools]#
8、拷貝、查看、設(shè)置屬主、及添加tmp權(quán)限
[root@mysql tools]# \cp mysql-5.5.16/support-files/my-small.cnf /etc/my.cnf [root@mysql tools]# ll /usr/local/mysql/data/ total 0 drwxr-xr-x 2 root root 20 May 31 11:51 test [root@mysql tools]# chown -R mysql.mysql /usr/local/mysql/data/ [root@mysql tools]# chmod -R 1777 /tmp/ [root@mysql tools]#
9、初始化數(shù)據(jù)庫
[root@mysql tools]# cd /usr/local/mysql/scripts/ [root@mysql scripts]# ./mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql Installing MySQL system tables… OK Filling help tables… OK
注:看到兩個ok表示成功
10、設(shè)置開機(jī)啟動
[root@mysql scripts]# cd /roottools/mysql-5.5.16 [root@mysql mysql-5.5.16]# cp support-files/mysql.server /etc/init.d/mysqld [root@mysql mysql-5.5.16]# chmod -R 755 /etc/init.d/mysqld [root@mysql mysql-5.5.16]# chkconfig --add mysqld [root@mysql mysql-5.5.16]# chkconfig mysqld on [root@mysql mysql-5.5.16]# chkconfig --list mysqld Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use ‘systemctl list-unit-files'. To see services enabled on particular target use ‘systemctl list-dependencies [target]'. mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@mysql mysql-5.5.16]#
11、啟動mysql數(shù)據(jù)庫
[root@mysql mysql-5.5.16]# /etc/init.d/mysqld start Starting MySQL… SUCCESS! [root@mysql mysql-5.5.16]#
12、查看端口進(jìn)程
[root@mysql mysql-5.5.16]# lsof -i:3306 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME mysqld 51146 mysql 10u IPv4 82600 0t0 TCP :mysql (LISTEN) [root@mysql mysql-5.5.16]# netstat -lnutp|grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0: LISTEN 51146/mysqld [root@mysql mysql-5.5.16]# ps -ef|grep 3306 mysql 51146 50900 0 14:13 pts/1 00:00:00 /usr/local/mysql-5.5.16/bin/mysqld --basedir=/usr/local/mysql-5.5.16 --datadir=/usr/local/mysql-5.5.16/data --plugin-dir=/usr/local/mysql-5.5.16/lib/plugin --user=mysql --log-error=/usr/local/mysql-5.5.16/data/mysql.err --pid-file=/usr/local/mysql-5.5.16/data/mysql.pid --socket=/usr/local/mysql-5.5.16/tmp/mysql.sock --port=3306 root 51170 16240 0 14:14 pts/1 00:00:00 grep --color=auto 3306 [root@mysql mysql-5.5.16]#
注:如果要重新初始化只要刪除data目錄庫文件存儲地或者新建一個庫文件存儲地,重新初始化,提示兩個ok就是成功
進(jìn)入數(shù)據(jù)庫
[root@localhost ~]# mysql
查看所有用戶
mysql> use mysql mysql> show tables; mysql> select user,host from user;
刪除系統(tǒng)默認(rèn)的
delete from mysql.user where user=''; delete from mysql.user where host='::1'; select user,host from mysql.user;
只保留這兩個
mysql> select user,host from mysql.user; ±-----±----------+ | user | host | ±-----±----------+ | root | 127.0.0.1 | | root | localhost | ±-----±----------+ 2 rows in set (0.00 sec) mysql> #########################
添加額外的授權(quán)管理員用戶
grant all privileges on . to system@‘192.168.%' identified by ‘system' with grant option;
字符集路徑
vi /etc/locale.conf #centos7
mysql創(chuàng)建密碼
/application/mysql//bin/mysqladmin -u root password ‘123456'
mysql修改密碼
/application/mysql//bin/mysqladmin -u root -p123456 password ‘112233'
總結(jié)
以上所述是小編給大家介紹的linux下使用cmake編譯安裝mysql的詳細(xì)教程,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
相關(guān)文章
Linux環(huán)境下快速搭建ftp服務(wù)器方法介紹
這篇文章主要介紹了Linux環(huán)境下快速搭建ftp服務(wù)器方法介紹,分享了相關(guān)代碼示例,小編覺得還是挺不錯的,具有一定借鑒價值,需要的朋友可以參考下2018-01-01
CentOS6.5 升級 Python 2.7 版本詳細(xì)介紹
這篇文章主要介紹了 CentOS6.5 升級 Python 2.7 版本詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下2017-01-01
centos服務(wù)器下nginx圖片防盜鏈設(shè)置方法
本篇文章主要介紹了centos服務(wù)器下nginx防盜鏈設(shè)置方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-03-03
Linux系統(tǒng)重啟后MySQL數(shù)據(jù)丟失問題的解決步驟
今天分享一個在Linux系統(tǒng)中經(jīng)常遇到的問題:系統(tǒng)重啟后發(fā)現(xiàn)MySQL無法啟動,而且數(shù)據(jù)似乎丟失了,這個問題可能會讓人驚慌失措,但別擔(dān)心,通常情況下這只是因?yàn)閿?shù)據(jù)盤沒有正確掛載導(dǎo)致的,現(xiàn)在我們將深入探討這個問題的原因、解決方法以及如何預(yù)防它的再次發(fā)生2024-09-09
手把手教你啟用Win10的Linux子系統(tǒng)(圖文超詳細(xì))
這篇文章主要介紹了手把手教你啟用Win10的Linux子系統(tǒng)(圖文超詳細(xì)),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12
移植busybox構(gòu)建最小根文件系統(tǒng)的步驟詳解
這篇文章主要介紹了移植busybox構(gòu)建最小根文件系統(tǒng)的步驟,本文分為五部給大家介紹的非常詳細(xì),需要的朋友可以參考下2019-07-07
解決nginx/apache靜態(tài)資源跨域訪問問題詳解
有時為了優(yōu)化網(wǎng)站訪問速度,會給一些靜態(tài)資源配置cdn加速,但是有時候會出現(xiàn)跨域訪問的問題,在nginx和apache服務(wù)中可進(jìn)行如下配置2018-10-10

