導航:首頁 > 源碼編譯 > 內存編譯安裝mysql

內存編譯安裝mysql

發布時間:2023-05-10 12:17:41

① 如何安裝mysql

  1. 要是你的是win操作系統的話,建議去官方網站下載mysql壓縮包,解壓出來就可以直接使用,使用過程

    首先在mysql解壓路徑下,進入bin文件夾,打開mysqld文件,然後使用cmd進入到該目錄,使用命令行登錄: mysql -u root -p(默認不需要密碼),但是每一次開啟資料庫都要首先打開mysqld進程,而且確保3306埠沒有被佔用

  2. 為方便使用打開mysql,所以自己參考網上大神例子寫了一個簡單的bat文件

  3. ::May262016By3306

    @echooff
    echo/*--------------3306--------------*/
    echo**
    echo*Lifesucks,dealwithit:)*
    echo**
    echo*Mysqlliftoff*
    echo**
    echo/*----------------------------------*/


    ::mysql解壓文件夾盤符
    D:


    ::進入mysqlbin文件夾
    cdProToolsMySQLmysql-5.5.47-winx64in::啟動mysqld服務
    mysqldpause
  4. linux系統的話,如果是centos,直接使用yum 來安裝最方便

② 在linux安裝MySQL時採用源碼編譯安裝,但是如何讓MySQL的編譯時間縮短呢

可以試試在使用make && make install 時添加-j參數,不限制內核進行編譯安裝。或者-j 後加內核數 。例如 make -j 4 && make install -j 4
優點:速度快會相對提高很多
缺點:消耗大量CPU,內存資源。
我做過一個測試,如果不限定內核 (16核 80GB內存 )的伺服器編譯安裝mysql 5.0.7 安裝時長大致在10分鍾左右,但是測試時伺服器CPU跑滿100% ,內存消耗至少32GB。直接使用 make && make install 安裝耗時45分鍾,內存4GB ,CPU 10%左右。

③ 詳細講解Linux環境下MySQL 5.1安裝步驟

1、下載MySQL免安裝版/二進製版軟體
(不用編譯)
文件格式:MYSQL-VERSION-OS.tar.gz
2、創建MySQL組,建立MySQL用戶並加入到mysql組中
(不同版本的Unix中,groupadd和useradd的語法可能會稍有不同。)
#groupadd
mysql
#useradd
-g
mysql
mysql
3、進入目錄/usr/local,解壓縮免安裝版,並在此目錄中建立名為mysql的軟鏈接
#cd
/usr/local
#gunzip
<
/path/to/MYSQL-VERSION-OS.tar.gz
|
tar
xvf
-
(該命令會在本目錄下創建一個名為MYSQL-VERSION-OS的新目錄。)
(使用GNU
tar,則不再需要gunzip。你可以直接用下面的命令來解包和提取分發:
#>
tar
zxvf
/path/to/mysql-VERSION-OS.tar.gz)
#ln
-s
MYSQL-VERSION-OS
mysql
4、添加MySQL配置文件
如果你想要設置一個選項文件,使用support-files目錄中的一個作為模板。在這個目錄中有4個模板文件,是根據不同機器的內存定製的。
#cp
support-files/my-medium.cnf
/etc/my.cnf
(可能你需要用root用戶運行這些命令。)
5、設定目錄訪問許可權,用mysql_install_db創建MySQL授權表初始化,並設置mysql,root帳號訪問許可權
#cd
mysql
#chown
-R
mysql
.
#chgrp
-R
mysql
.
#scripts/mysql_install_db
–user=mysql
#chown
-R
root
.
#chown
-R
mysql
data
(注意以上命令中的"
.
"符號不能少。)
6、運行MySQL
#bin/mysqld_safe
–user=mysql
&
(如果沒有問題的話,應該會出現類似這樣的提示:
[1]
42264
#
Starting
mysqld
daemon
with
databases
from
/usr/local/mysql/var
如果出現
mysql
ended這樣的語句,表示Mysql沒有正常啟動,你可以到log中查找問題,Log文件的通常在/etc/my.cnf中配置。
大多數問題是許可權設置不正確引起的。
)
7、設置root密碼。默認安裝密碼為空,為了安全你需要修改密碼
#/usr/local/mysql/bin/mysqladmin
-uroot
password
yourpassword
8、拷貝編譯目錄的一個腳本,設置開機自動啟動
#cp
support-files/mysql.server
/etc/rc.d/init.d/mysqld
#chmod
700
/etc/init.d/mysqld
#chkconfig
–add
mysqld
#chkconfig
–level
345
mysqld
on
9、啟動mysqld服務
#service
mysqld
start
10、查看3306埠是否打開。要注意在防火牆中開放該埠
#netstat
-atln
免安裝版/二進製版安裝基本命令概述:
shell>
groupadd
mysql
shell>
useradd
-g
mysql
mysql
shell>
cd
/usr/local
shell>
gunzip
<
/PATH/TO/MYSQL-VERSION-OS.tar.gz
|
tar
xvf
-
shell>
ln
-s
FULL-PATH-TO-MYSQL-VERSION-OS
mysql
shell>
cd
mysql
shell>
chown
-R
mysql
.
shell>
chgrp
-R
mysql
.
shell>
scripts/mysql_install_db
–user=mysql
shell>
chown
-R
root
.
shell>
chown
-R
mysql
data
shell>
bin/mysqld_safe
–user=mysql
&

④ MYSQL怎麼安裝啊

WINDOWS很簡單,就不說了。 linux安裝mysql #tarzxvfmysql-4.0.14.tar.gz-C/setup #cd/setup/mysql-4.0.14 #groupaddmysql #useraddmysql-gmysql-M-s/bin/false #./configure--prefix=/web/mysql指定安裝目錄 --without-debug去除debug模式 --with-extra-charsets=gb2312添加gb2312中文字元支持 --enable-assembler使用一些字元函數的匯編版本 --without-isam去掉isam表類型支持現在很少用了isam表是一種依賴平台的表 --without-innodb去掉innodb表支持innodb是一種支持事務處理的表,適合企業級應用 --with-pthread強制使用pthread庫(posix線程庫) --enable-thread-safe-client以線程方式編譯客戶端 --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static以純靜態方式編譯服務端和客戶端--with-raid激活raid支持 #make #makeinstall #scripts/mysql_install_db生成mysql用戶資料庫和表文件 #cpsupport-files/my-medium.cnf/etc/my.cnf配置文件,有large,medium,small三個環境下的,根據機器性能選擇,如果負荷比較大,可修改裡面的一些變數的內存使用值 #cpsupport-files/mysql.server/etc/init.d/mysqld啟動的mysqld文件 #chmod700/etc/init.d/mysqld #cd/web #chmod750mysql-R #chgrpmysqlmysql-R #chownmysqlmysql/var-R #cd/web/mysql/libexec #cpmysqldmysqld.old #stripmysqld #chkconfig--addmysqld #chkconfig--level345mysqldon #servicemysqldstart #netstat-atln 看看有沒有3306的埠打開,如果mysqld不能啟動,看看/web/mysql/var下的出錯日誌,一般都是目錄許可權沒有設置好的問題 #ln-s/web/mysql/bin/mysql/sbin/mysql #ln-s/web/mysql/bin/mysqladmin/sbin/mysqladmin #mysqladmin-urootpassword"youpassword"#設置root帳戶的密碼 #mysql-uroot-p #輸入你設置的密碼 mysql>usemysql; mysql>deletefromuserwherepassword="";#刪除用於本機匿名連接的空密碼帳號 mysql>flushprivileges; mysql>quit ●安裝DBI和DBDformysql用於提供perl訪問mysql資料庫的介面規范,請確認你已經安裝了perl,一般默認系統都裝上了

⑤ linux上怎麼安裝mysql

1. 運行平台:CentOS 6.3 x86_64,基本等同於RHEL 6.3
2. 安裝方法:
安裝MySQL主要有兩種方法:一種是通過源碼自行編譯安裝,這種適合高級用戶定製MySQL的特性,這里不做說明;另一種是通過編譯過的二進制文件進行安裝。二進制文件安裝的方法又分為兩種:一種是不針對特定平台的通用安裝方法,使用的二進制文件是後綴為.tar.gz的壓縮文件;第二種是使用RPM或其他包進行安裝,這種安裝進程會自動完成系統的相關配置,所以比較方便。
3. 下載安裝包:
2. 下載文件(根據操作系統選擇相應的發布版本):
a. 通用安裝方法
mysql-5.5.29-linux2.6-x86_64.tar.gz
b. RPM安裝方法:
MySQL-server-5.5.29-2.el6.x86_64.rpm
MySQL-client-5.5.29-2.el6.x86_64.rpm
4. 通用安裝步驟
a. 檢查是否已安裝,grep的-i選項表示匹配時忽略大小寫
[root@localhost JavaEE]#rpm -qa|grep -i mysql
mysql-libs-5.1.61-4.el6.x86_64
*可見已經安裝了庫文件,應該先卸載,不然會出現覆蓋錯誤。注意卸:載時使用了--nodeps選項,忽略了依賴關系:
[root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
b. 添加mysql組和mysql用戶,用於設置mysql安裝目錄文件所有者和所屬組。
[root@localhost JavaEE]#groupadd mysql
[root@localhost JavaEE]#useradd -r -g mysql mysql
*useradd -r參數表示mysql用戶是系統用戶,不可用於登錄系統。
c. 將二進制文件解壓到指定的安裝目錄,我們這里指定為/usr/local
[root@localhost ~]# cd/usr/local/
[root@localhost local]#tar zxvf /path/to/mysql-5.5.29-linux2.6-x86_64.tar.gz
*加壓後在/usr/local/生成了解壓後的文件夾mysql-5.5.29-linux2.6-x86_64,這名字太長,我們為它建立一個符號鏈接mysql,方便輸入。
[root@localhost local]#ln -s mysql-5.5.29-linux2.6-x86_64 mysql
d. /usr/local/mysql/下的目錄結構

Directory

Contents of Directory

bin

Client programs and the mysqld server

data

Log files, databases

docs

Manual in Info format

man

Unix manual pages

include

Include (header) files

lib

Libraries

scripts

mysql_install_db

share

Miscellaneous support files, including error messages, sample configuration files, SQL for database installation

sql-bench

Benchmarks

e. 進入mysql文件夾,也就是mysql所在的目錄,並更改所屬的組和用戶。
[root@localhost local]#cd mysql
[root@localhost mysql]#chown -R mysql .
[root@localhost mysql]#chgrp -R mysql .
f. 執行mysql_install_db腳本,對mysql中的data目錄進行初始化並創建一些系統表格。注意mysql服務進程mysqld運行時會訪問data目錄,所以必須由啟動mysqld進程的用戶(就是我們之前設置的mysql用戶)執行這個腳本,或者用root執行,但是加上參數--user=mysql。
[root@localhost mysql]scripts/mysql_install_db --user=mysql
*如果mysql的安裝目錄(解壓目錄)不是/usr/local/mysql,那麼還必須指定目錄參數,如
[root@localhost mysql]scripts/mysql_install_db --user=mysql \
--basedir=/opt/mysql/mysql \
--datadir=/opt/mysql/mysql/data
*將mysql/目錄下除了data/目錄的所有文件,改回root用戶所有,mysql用戶只需作為mysql/data/目錄下所有文件的所有者。
[root@localhost mysql]chown -R root .
[root@localhost mysql]chown -R mysql data
g. 復制配置文件
[root@localhost mysql] cp support-files/my-medium.cnf /etc/my.cnf
h. 將mysqld服務加入開機自啟動項。
*首先需要將scripts/mysql.server服務腳本復制到/etc/init.d/,並重命名為mysqld。
[root@localhostmysql] cp support-files/mysql.server /etc/init.d/mysqld
*通過chkconfig命令將mysqld服務加入到自啟動服務項中。
[root@localhost mysql]#chkconfig --add mysqld
*注意服務名稱mysqld就是我們將mysql.server復制到/etc/init.d/時重命名的名稱。
*查看是否添加成功
[root@localhost mysql]#chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
i. 重啟系統,mysqld就會自動啟動了。
*檢查是否啟動
[root@localhost mysql]#netstat -anp|grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2365/mysqld
unix 2 [ ACC ] STREAM LISTENING 14396 2365/mysqld /tmp/mysql.sock
*如果不想重新啟動,那可以直接手動啟動。
[root@localhost mysql]#service mysqld start
Starting MySQL.. SUCCESS!
j. 運行客戶端程序mysql,在mysql/bin目錄中,測試能否連接到mysqld。
[root@localhost mysql]#/usr/local/mysql/bin/mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 2
Server version:5.5.29-log MySQL Community Server (GPL)

Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its affiliates. Other names may betrademarks of their respective owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql> quit
Bye
*此時會出現mysql>命令提示符,可以輸入sql語句,輸入quit或exit退出。為了避免每次都輸入mysql的全路徑/usr/local/mysql/bin/mysql,可將其加入環境變數中,在/etc/profile最後加入兩行命令:
MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
這樣就可以在shell中直接輸入mysql命令來啟動客戶端程序了
[root@localhost mysql]#mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 3
Server version:5.5.29-log MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registeredtrademark of Oracle Corporation and/or its
affiliates. Other namesmay be trademarks of their respective
owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql>

5. RPM安裝步驟
a. 檢查是否已安裝,grep的-i選項表示匹配時忽略大小寫
[root@localhost JavaEE]#rpm -qa|grep -i mysql
mysql-libs-5.1.61-4.el6.x86_64
可見已經安裝了庫文件,應該先卸載,不然會出現覆蓋錯誤。注意卸載時使用了--nodeps選項,忽略了依賴關系:
[root@localhost JavaEE]#rpm -e mysql-libs-5.1.61-4.el6.x86_64 --nodeps
2. 安裝MySQL的伺服器端軟體,注意切換到root用戶:
[root@localhost JavaEE]#rpm -ivh MySQL-server-5.5.29-2.el6.x86_64.rpm
安裝完成後,安裝進程會在Linux中添加一個mysql組,以及屬於mysql組的用戶mysql。可通過id命令查看:
[root@localhost JavaEE]#id mysql
uid=496(mysql)gid=493(mysql) groups=493(mysql)
MySQL伺服器安裝之後雖然配置了相關文件,但並沒有自動啟動mysqld服務,需自行啟動:
[root@localhost JavaEE]#service mysql start
Starting MySQL.. SUCCESS!
可通過檢查埠是否開啟來查看MySQL是否正常啟動:
[root@localhost JavaEE]#netstat -anp|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 34693/mysqld
c. 安裝MySQL的客戶端軟體:
[root@localhost JavaEE]#rpm -ivh MySQL-client-5.5.29-2.el6.x86_64.rpm
如果安裝成功應該可以運行mysql命令,注意必須是mysqld服務以及開啟:
[root@localhost JavaEE]#mysql
Welcome to the MySQLmonitor. Commands end with ; or \g.
Your MySQL connection idis 1
Server version: 5.5.29MySQL Community Server (GPL)
Copyright (c) 2000, 2012,Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademarkof Oracle Corporation and/or its affiliates. Other names may be trademarks oftheir respective owners.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
mysql>

⑥ linux怎麼安裝mysql

一般有下面幾種方法:(以紅帽系Linux為例)
1、yum install mysql mysql-server
這種版本通常比較舊
2、rpm包離線安裝
需要先去MySQL官網下載rpm包
3、源碼編譯安裝
需要先去MySQL官網下載源碼
詳細安裝方法建議網路搜一下MySQL安裝教程。

閱讀全文

與內存編譯安裝mysql相關的資料

熱點內容
我的世界國際服為什麼登不進伺服器 瀏覽:994
微盟程序員老婆 瀏覽:928
intellij創建java 瀏覽:110
java連接odbc 瀏覽:38
啟動修復無法修復電腦命令提示符 瀏覽:359
手機編程是什麼 瀏覽:97
山東移動程序員 瀏覽:163
蘇州java程序員培訓學校 瀏覽:476
單片機液晶驅動 瀏覽:854
魔拆app里能拆到什麼 瀏覽:130
新預演算法的立法理念 瀏覽:144
wdcpphp的路徑 瀏覽:134
單片機p0口電阻 瀏覽:926
瀏覽器中調簡訊文件夾 瀏覽:594
五菱宏光空調壓縮機 瀏覽:68
為什麼app佔用幾百兆 瀏覽:680
自動解壓失敗叫我聯系客服 瀏覽:484
易語言新手源碼 瀏覽:456
oa伺服器必須有固定ip地址 瀏覽:45
傳奇源碼分析是什麼 瀏覽:270