国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

MySQL5.5源碼安裝的流程

發(fā)布時(shí)間:2021-09-27 17:43 來(lái)源:億速云 閱讀:0 作者:chen 欄目: Mysql 歡迎投稿:712375056

這篇文章主要講解了“5.5源碼安裝的流程”,文中的講解內容簡(jiǎn)單清晰,易于學(xué)習與理解,下面請大家跟著(zhù)小編的思路慢慢深入,一起來(lái)研究和學(xué)習“MySQL5.5源碼安裝的流程”吧!

源碼安裝的系統需求:
MySQL的源碼安裝需要下面的一些開(kāi)發(fā)工具。

CMake 用來(lái)在所有平臺上構建框架
優(yōu)秀的 make 程序。推薦使用GNU make 3.75或更新的版本。
ANSI C++編輯器。GCC 4.2.1或更高版本,Sun Studio 12或更新的版本, Visual Studio 2008或更新的版本。
需要足夠的內存。如果當在編譯大的源文件時(shí)報"internal compiler error",則可能是系統的內存太小了。
如果你要運行測試腳本,需要安裝Perl。大多數的類(lèi)Unix系統包含Perl。在Windows系統下,可以安裝ActiveState Perl。

安裝需要的包

[root@localhost ~]# yum install gcc-c++
[root@localhost ~]# yum install libaio-devel
[root@localhost ~]# yum install ncurses-devel
[root@localhost ~]# yum install numactl-devel
[root@localhost ~]# yum install openssl-devel
[root@localhost ~]# yum install gperf

安裝rpm-build包
[root@localhost yum.repos.d]# yum install rpm-build

安裝cmake2.8.2
去https://cmake.org/download/下載cmake的源碼安裝包
[root@localhost install]# wget http://www.cmake.org/files/v2.8/cmake-2.8.2.tar.gz --no-check-certificate

解壓
[root@localhost install]# gzip -d cmake-2.8.2.tar.gz
[root@localhost install]# tar fvx cmake-2.8.2.tar

[root@localhost install]# cd cmake-2.8.2
[root@localhost cmake-2.8.2]# ./bootstrap

編譯安裝
[root@localhost cmake-2.8.2]# make
[root@localhost cmake-2.8.2]# make install

查看版本
[root@localhost cmake-2.8.2]# cmake -version
cmake version 2.8.2

如果創(chuàng )建二進(jìn)制rpm安裝文件,則通過(guò)下面命令生成
[root@localhost install]# rpmbuild --rebuild --clean MySQL-5.5.48-1.el6.src.rpm --define='runselftest 0'

查看生成的RPM文件
[root@localhost x86_64]# cd /root/rpmbuild/RPMS/x86_64
[root@localhost x86_64]# ll
total 142788
-rw-r--r--. 1 root root 15333376 Mar 28 23:11 MySQL-client-5.5.48-1.linux2.6.x86_64.rpm
-rw-r--r--. 1 root root  4992448 Mar 28 23:12 MySQL-devel-5.5.48-1.linux2.6.x86_64.rpm
-rw-r--r--. 1 root root 51994352 Mar 28 23:12 MySQL-embedded-5.5.48-1.linux2.6.x86_64.rpm
-rw-r--r--. 1 root root 39075180 Mar 28 23:11 MySQL-server-5.5.48-1.linux2.6.x86_64.rpm
-rw-r--r--. 1 root root  1753148 Mar 28 23:12 MySQL-shared-5.5.48-1.linux2.6.x86_64.rpm
-rw-r--r--. 1 root root 33055692 Mar 28 23:12 MySQL-test-5.5.48-1.linux2.6.x86_64.rpm

如果編譯源碼方式安裝,則執行下面命令

[root@localhost install]# rpm -ivh MySQL-5.5.48-1.el6.src.rpm 
warning: MySQL-5.5.48-1.el6.src.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
   1:MySQL                  ########################################### [100%]

手動(dòng)創(chuàng )建Mysql用戶(hù)和組
[root@localhost install]# groupadd mysql
[root@localhost install]# useradd -r -g mysql -s /bin/false mysql

解壓生成的包
[root@localhost SOURCES]# cd /root/rpmbuild
[root@localhost rpmbuild]# ls -trl
total 24
drwxr-xr-x. 2 root root 4096 Mar 28 05:02 SRPMS
drwxr-xr-x. 3 root root 4096 Mar 28 23:11 RPMS
drwxr-xr-x. 2 root root 4096 Mar 28 23:12 BUILDROOT
drwxr-xr-x. 2 root root 4096 Mar 28 23:12 BUILD
drwxr-xr-x. 2 root root 4096 Mar 28 23:41 SPECS
drwxr-xr-x. 3 root root 4096 Mar 28 23:46 SOURCES
[root@localhost rpmbuild]# cd SOURCES/
[root@localhost SOURCES]# ls -trl
total 20712
-rw-r--r--.  1 root root  21201193 Jan 14 18:48 mysql-5.5.48.tar.gz
[root@localhost SOURCES]# tar zxvf mysql-5.5.48.tar.gz 

開(kāi)始編譯
[root@localhost SOURCES]# ll
total 20712
drwxr-xr-x. 31 7161 wheel     4096 Jan 14 18:47 mysql-5.5.48
-rw-r--r--.  1 root root  21201193 Jan 14 18:48 mysql-5.5.48.tar.gz
[root@localhost SOURCES]# cd mysql-5.5.48

[root@localhost mysql-5.5.48]# cmake . -DCMAKE_INSTALL_PREFIX=/software \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DCOMPILATION_COMMENT='production environment' \
-DWITH_READLINE=ON \
-DSYSCONFDIR=/software \
-DMYSQL_UNIX_ADDR=/data/mysql.sock \
-DMYSQL_DATADIR=/data


[root@localhost mysql-5.5.48]# make
Linking CXX executable mysql_tzinfo_to_sql
[100%] Built target mysql_tzinfo_to_sql
Scanning dependencies of target mysqld
[100%] Building CXX object sql/CMakeFiles/mysqld.dir/main.cc.o
Linking CXX executable mysqld
[100%] Built target mysqld
Scanning dependencies of target udf_example
[100%] Building C object sql/CMakeFiles/udf_example.dir/udf_example.c.o
Linking C shared module udf_example.so
[100%] Built target udf_example
Scanning dependencies of target my_safe_process
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[100%] Built target my_safe_process

[root@localhost mysql-5.5.48]# make install
-- Installing: /data/man/man1/perror.1
-- Installing: /data/man/man1/mysqld_multi.1
-- Installing: /data/man/man1/mysql_client_test_embedded.1
-- Installing: /data/man/man1/msql2mysql.1
-- Installing: /data/man/man1/mysqlman.1
-- Installing: /data/man/man1/comp_err.1
-- Installing: /data/man/man8/mysqld.8

[root@localhost software# cd /software
[root@localhost software# ll
total 220
drwxr-xr-x.  2 root root   4096 Mar 29 00:06 bin
-rw-r--r--.  1 root root  17987 Jan 14 18:38 COPYING
drwxr-xr-x.  3 root root   4096 Mar 29 00:05 data
drwxr-xr-x.  2 root root   4096 Mar 29 00:05 docs
drwxr-xr-x.  3 root root   4096 Mar 29 00:05 include
-rw-r--r--.  1 root root 151708 Jan 14 18:47 INSTALL-BINARY
drwxr-xr-x.  3 root root   4096 Mar 29 00:05 lib
drwxr-xr-x.  4 root root   4096 Mar 29 00:06 man
drwxr-xr-x. 10 root root   4096 Mar 29 00:06 mysql-test
-rw-r--r--.  1 root root   2496 Jan 14 18:38 README
drwxr-xr-x.  2 root root   4096 Mar 29 00:06 scripts
drwxr-xr-x. 27 root root   4096 Mar 29 00:06 share
drwxr-xr-x.  4 root root   4096 Mar 29 00:06 sql-bench
drwxr-xr-x.  2 root root   4096 Mar 29 00:06 support-files

更改MySQL安裝軟件的權限為mysql
[root@localhost software]# chown -R mysql .
[root@localhost software]# chgrp -R mysql .

初始化MySQL數據的數據文件路徑,并且創(chuàng )建系統表

[root@localhost data]# scripts/mysql_install_db --user=mysql  --datadir=/data
Installing MySQL system tables...
160329  0:21:08 [Note] ./bin/mysqld (mysqld 5.5.48) starting as process 25151 ...
OK
Filling help tables...
160329  0:21:08 [Note] ./bin/mysqld (mysqld 5.5.48) starting as process 25158 ...
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:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
./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 . ; ./bin/mysqld_safe &

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

Please report any problems at http://bugs.mysql.com/

[root@localhost software]# chown -R root .
[root@localhost software]# chown -R mysql data

[root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y

啟動(dòng)數據庫
發(fā)生報錯
[root@localhost data]# ./bin/mysqld_safe --defaults-file=/etc/my.cnf &
[1] 1053
[root@localhost data]# 160330 01:36:51 mysqld_safe Logging to '/var/log/mysqld.log'.
160330 01:36:51 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
160330 01:36:52 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

[1]+  Done                    bin/mysqld_safe --user=mysql

查看報錯日志,報錯原因是mysql沒(méi)有指定路徑的讀寫(xiě)權限,導致無(wú)法創(chuàng )建進(jìn)程文件
[root@localhost data]# vim /var/log/mysqld.log
160330  1:36:52 [ERROR] /data/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13)
160330  1:36:52 [ERROR] Can't start server: can't create PID file: Permission denied

創(chuàng )建對應路徑,并授權

[root@localhost install]# mkdir -p /var/run/mysqld/
[root@localhost install]# chown -R mysql.mysql /var/run/mysqld/

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql.server

編輯配置文件

[root@localhost mysql]# vim /etc/my.cnf
[client]
port = 3306
socket = /data/mysql.sock

# Mysql server
[mysqld]
port = 3306
user = mysql
socket = /data/mysql.sock
pid-file = /var/run/mysqld/mysqld.pid
basedir = /software
datadir = /data
#tmpdir = 
open_files_limit = 10240
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# Buffer
max_allowed_packet = 256M
max_heap_table_size = 256M
net_buffer_length = 8K
sort_buffer_size = 4M
join_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 16M

# Log
log-bin = /log/binlog/mysql-bin
binlog_cache_size = 32M
max_binlog_cache_size = 512M
max_binlog_size = 512M
binlog_format = MIXED
log_output = FILE
log_error = /log/err.log
slow_query_log = 1
slow_query_log_file = /log/slow_query.log
general_log = 0
general_log_file = /log/general_query.log

# InnoDB
innodb_data_file_path = ibdata1:12M:autoextend
#innodb_log_file_size = 256M
#innodb_log_files_in_group = 3
innodb_buffer_pool_size = 100M

# Character set
#character_set_server = gbk
#collation_server = gbk_bin

[mysql]
no-auto-rehash
default-character-set = gbk

啟動(dòng)MySQL數據庫

[root@localhost data]# ./bin/mysqld_safe --defaults-file=/etc/my.cnf &
[1] 5774

[root@localhost data]# 160330 01:37:51 mysqld_safe Logging to '/var/log/mysqld.log'.

160330 01:37:51 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

[root@localhost data]# ps -ef|grep mysql
root      1231 55613  0 01:37 pts/2    00:00:00 /bin/sh bin/mysqld_safe --user=mysql
mysql     1401  1231  0 01:37 pts/2    00:00:00 /data/bin/mysqld --basedir=/data --datadir=/var/lib/mysql --plugin-
dir=/data/lib/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --
socket=/var/lib/mysql/mysql.sock
root      1421 55613  0 01:38 pts/2    00:00:00 grep mysql

更改root用戶(hù)密碼
[root@localhost data]# ./bin/mysqladmin -u root password 'Mysql#2015'

刪除數據庫中多余的root用戶(hù)和匿名用戶(hù),只在本地保留一個(gè)root用戶(hù)
mysql> delete from mysql.user where (user,host) not in (select 'root','localhost');
Query OK, 4 rows affected (0.00 sec)

更改root的用戶(hù)名
mysql> update mysql.user set user='system',password=password('Mysql#2015') where user='root';
Query OK, 1 row affected (0.09 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> truncate table mysql.db;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。

国产成人无码午夜视频在线观看| 无码中文字幕av免费放| 中文字幕av一区| 久久久久亚洲AV无码专区导航| 极品少妇被猛的白浆直喷白浆| 中文天堂在线资源www|