亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Linux下如何安裝配置源代碼版本的MySQL

發布時間:2021-11-01 11:43:11 來源:億速云 閱讀:115 作者:小新 欄目:MySQL數據庫

這篇文章主要為大家展示了“Linux下如何安裝配置源代碼版本的MySQL”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“Linux下如何安裝配置源代碼版本的MySQL”這篇文章吧。



操作系統版本:Red Hat Enterprise Linux Server release 5 (Tikanga)
MySQL版本:
安裝文件:MySQL-community-5.1.45-1.rhel5.src.rpm


 1.釋放源代碼包

   使用的安裝文件是一個source RPM,首先要將其內容釋放:

方法一:

[root@redhat5-db-1 software]# rpm -i MySQL-community-5.1.45-1.rhel5.src.rpm
error: cannot create %sourcedir /usr/src/redhat/SOURCES
[root@redhat5-db-1 software]# mkdir -p /usr/src/redhat/SOURCES
[root@redhat5-db-1 software]# rpm -i MySQL-community-5.1.45-1.rhel5.src.rpm
warning: user mysqldev does not exist - using root
warning: group mysqldev does not exist - using root
warning: user mysqldev does not exist - using root
warning: group mysqldev does not exist - using root
[root@redhat5-db-1 software]# ls /usr/src/redhat/*
/usr/src/redhat/SOURCES:
mysql-5.1.45.tar.gz

/usr/src/redhat/SPECS:
mysql-5.1.45.rhel5.spec

[@more@]方法二:

[root@redhat5-db-1 software]# rpm2cpio MySQL-community-5.1.45-1.rhel5.src.rpm | cpio -idmv
mysql-5.1.45.rhel5.spec
mysql-5.1.45.tar.gz
43995 blocks
[root@redhat5-db-1 software]# ls
mysql-5.1.45.rhel5.spec  mysql-5.1.45.tar.gz  MySQL-community-5.1.45-1.rhel5.src.rpm

注:無論使用哪種方法,都會在釋放源代碼包的同時,釋放另一個文件 mysql-5.1.45.rhel5.spec 。它是一個RPM SPEC文件,可以通過rpmbuild命令創建MySQL的源代碼文件或二進制程序(-bp選項在 /usr/src/redhat/BUILD 目錄下創建源代碼文件,-bb選項在 /usr/src/redhat/RPM 目錄下創建二進制程序),這里不再贅述。


 2.安裝前的準備工作

 1)創建用戶和組

[root@redhat5-db-1 software]# groupadd mysql
[root@redhat5-db-1 software]# useradd -g mysql mysql
[root@redhat5-db-1 software]# id mysql
uid=502(mysql) gid=504(mysql) groups=504(mysql)

 2)準備必要的目錄

[root@redhat5-db-1 software]# mkdir -p /opt/mysql /data/mysql
[root@redhat5-db-1 software]# chown mysql:mysql /opt/mysql /data/mysql

 3)安裝必要的RPM

   需要安裝ncurses-devel,否則編譯時會報如下錯誤:

checking for termcap functions library... configure: error: No curses/termcap library found

   在Red Hat EL 5安裝光盤中找到該RPM,進行安裝:

[root@redhat5-db-1 software]# mount -o ro /dev/cdrom /mnt/cdrom
[root@redhat5-db-1 software]# rpm -ivh /mnt/cdrom/Server/ncurses-devel-5.5-24.20060715.i386.rpm
warning: /mnt/cdrom/Server/ncurses-devel-5.5-24.20060715.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
  1:ncurses-devel          ########################################### [100%]

 4)解壓源代碼包

[root@redhat5-db-1 software]# tar -zxf mysql-5.1.45.tar.gz
[root@redhat5-db-1 software]# ls -p
mysql-5.1.45/  mysql-5.1.45.rhel5.spec  mysql-5.1.45.tar.gz  MySQL-community-5.1.45-1.rhel5.src.rpm


 3.安裝MySQL

 1)CONFIGURE

[root@redhat5-db-1 software]# su - mysql
[mysql@redhat5-db-1 ~]$ cd /opt/software/mysql-5.1.45
[mysql@redhat5-db-1 mysql-5.1.45]$ ./configure --prefix=/opt/mysql --localstatedir=/data/mysql --with-plugins=innobase
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c

......

config.status: executing depfiles commands
config.status: executing libtool commands
/bin/rm: cannot remove `libtoolT': No such file or directory
config.status: executing default commands

Thank you for choosing MySQL!

Remember to check the platform specific part of the reference manual
for hints about installing MySQL on your platform.
Also have a look at the files in the Docs directory.

注:--prefix選項指定MySQL程序的路徑;--localstatedir選項指定MySQL數據文件的路徑;--with-plugins=innobase 指定MySQL服務器包含InnoDB功能。

 2)MAKE

[mysql@redhat5-db-1 mysql-5.1.45]$ make
Making all in .
make[1]: Entering directory `/opt/software/mysql-5.1.45'
make abi_headers="include/mysql/plugin.h include/mysql.h" do_abi_check
make[2]: Entering directory `/opt/software/mysql-5.1.45'

......

Making all in win
make[1]: Entering directory `/opt/software/mysql-5.1.45/win'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/software/mysql-5.1.45/win'

 3)MAKE-INSTALL

[mysql@redhat5-db-1 mysql-5.1.45]$ make install
Making install in .
make[1]: Entering directory `/opt/software/mysql-5.1.45'
make abi_headers="include/mysql/plugin.h include/mysql.h" do_abi_check
make[2]: Entering directory `/opt/software/mysql-5.1.45'

......

Making install in win
make[1]: Entering directory `/opt/software/mysql-5.1.45/win'
make[2]: Entering directory `/opt/software/mysql-5.1.45/win'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/software/mysql-5.1.45/win'
make[1]: Leaving directory `/opt/software/mysql-5.1.45/win'
[mysql@redhat5-db-1 mysql-5.1.45]$ ls /opt/mysql
bin  docs  include  lib  libexec  mysql-test  share  sql-bench


 4.安裝后的工作

 1)創建選項文件

[root@redhat5-db-1 ~]# cp /opt/software/mysql-5.1.45/support-files/my-medium.cnf /etc/my.cnf
[root@redhat5-db-1 ~]# chown mysql:mysql /etc/my.cnf

   可以通過修改其內容對MySQL服務器進行配置。這里只簡單取消InnoDB相關參數所在行的注釋:

# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /data/mysql/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /data/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

 2)設置環境變量

   在mysql的HOME目錄下的.bash_profile文件中添加如下內容:

# Added by ggyy on March 31st, 2010
PATH=$PATH:/opt/mysql/bin
export PATH

 3)初始化MySQL

[mysql@redhat5-db-1 ~]$ /opt/mysql/bin/mysql_install_db
Installing MySQL system tables...
100331 18:21:59 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
Filling help tables...
100331 18:22:00 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/opt/mysql/bin/mysqladmin -u root password 'new-password'
/opt/mysql/bin/mysqladmin -u root -h redhat5-db-1 password 'new-password'

Alternatively you can run:
/opt/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /opt/mysql ; /opt/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /opt/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/mysql/bin/mysqlbug script!

[mysql@redhat5-db-1 ~]$ ls /data/mysql
mysql  mysql-bin.000001  mysql-bin.000002  mysql-bin.index  test

 3)啟動和關閉MySQL

   啟動MySQL服務器,測試登陸:

[mysql@redhat5-db-1 ~]$ /opt/mysql/bin/mysqld_safe &
[1] 3028
[mysql@redhat5-db-1 ~]$ 100331 18:27:18 mysqld_safe Logging to '/data/mysql/redhat5-db-1.err'.
100331 18:27:18 mysqld_safe Starting mysqld daemon with databases from /data/mysql

mysql> select version();
+------------+
| version()  |
+------------+
| 5.1.45-log |
+------------+
1 row in set (0.00 sec)

mysql> show variables like "have_innodb";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_innodb   | YES   |
+---------------+-------+
1 row in set (0.00 sec)

   可以使用mysql.server腳本啟動和關閉MySQL服務器,它位于解壓的源代碼目錄下的support-files子目錄中。該目錄下還有許多其它有用的文件、腳本,可以考慮將其復制到MySQL程序目錄下,并在.bash_profile文件里的PATH中添加相應路徑。

[mysql@redhat5-db-1 ~]$ cp -pr /opt/software/mysql-5.1.45/support-files /opt/mysql
[mysql@redhat5-db-1 ~]$ chmod u+x /opt/mysql/support-files/mysql.server
[mysql@redhat5-db-1 ~]$ which mysql.server
/opt/mysql/support-files/mysql.server
[mysql@redhat5-db-1 ~]$ mysql.server stop
Shutting down MySQL.100331 18:58:49 mysqld_safe mysqld from pid file /data/mysql/redhat5-db-1.pid ended
                                                          [  OK  ]


以上是“Linux下如何安裝配置源代碼版本的MySQL”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

赣榆县| 当涂县| 八宿县| 凤冈县| 库尔勒市| 太保市| 临江市| 陈巴尔虎旗| 江达县| 龙南县| 井陉县| 赤水市| 阜南县| 巫山县| 五大连池市| 奇台县| 瑞安市| 皋兰县| 宜黄县| 噶尔县| 静海县| 新余市| 诸城市| 盐源县| 乌苏市| 定西市| 彩票| 张家口市| 德安县| 北安市| 洛阳市| 越西县| 怀化市| 资源县| 衡山县| 明光市| 宜兰县| 阿克陶县| 会东县| 安徽省| 同德县|