1. 程式人生 > >九周第四次課(2月26日) 11.1 LAMP架構介紹 11.2 MySQL、MariaDB介紹 11.3/11.4/11.5 MySQL安裝 擴展 mysql5.5源碼編譯安裝

九周第四次課(2月26日) 11.1 LAMP架構介紹 11.2 MySQL、MariaDB介紹 11.3/11.4/11.5 MySQL安裝 擴展 mysql5.5源碼編譯安裝

when image safe x86 lease x86_64 roc use my.cnf


11.1 LAMP架構介紹
11.2 MySQL、MariaDB介紹
11.3/11.4/11.5 MySQL安裝
擴展
mysql5.5源碼編譯安裝 技術分享圖片http://www.aminglinux.com/bbs/thread-1059-1-1.html

mysql5.7二進制包安裝(變化較大) 技術分享圖片http://www.apelearn.com/bbs/thread-10105-1-1.html ==================================================================================================== 技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

技術分享圖片

==================================================================================================================================================================================================================

Last login: Mon Feb 26 20:46:31 2018
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# ls
httpd-2.2.34 httpd-2.2.34.tar.gz
[root@localhost src]# uname -a
Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost src]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
--2018-02-26 22:01:36-- http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
正在解析主機 mirrors.sohu.com (mirrors.sohu.com)... 221.236.12.140
正在連接 mirrors.sohu.com (mirrors.sohu.com)|221.236.12.140|:80... 已連接。
已發出 HTTP 請求,正在等待回應... 200 OK
長度:316320366 (302M) [application/octet-stream]
正在保存至: “mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz”

100%[=================================>] 316,320,366 2.40MB/s 用時 2m 6s

2018-02-26 22:03:43 (2.39 MB/s) - 已保存 “mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz” [316320366/316320366])

[root@localhost src]# ls
httpd-2.2.34 mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
httpd-2.2.34.tar.gz
[root@localhost src]# tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
mysql-5.6.36-linux-glibc2.5-x86_64/mysql-test/README
mysql-5.6.36-linux-glibc2.5-x86_64/mysql-test/purify.supp
mysql-5.6.36-linux-glibc2.5-x86_64/mysql-test/collections/README
mysql-5.6.36-linux-glibc2.5-x86_64/mysql-test/collections/default.weekly-valgrind
mysql-5.6.36-linux-glibc2.5-x86_64/mysql-test/collections/disabled-gtid-on.list
====================================解壓部分刪除(太多了~)==================================================================================================================================================================================================================
[root@localhost src]# http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
-bash: http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz: 沒有那個文件或目錄
[root@localhost src]# mv mysql-5.6.36-linux-glibc2.5-x86_64 /usr/local/mysql
[root@localhost src]# cd /usr/local/mysql/
[root@localhost mysql]# ls
bin data include man README share support-files
COPYING docs lib mysql-test scripts sql-bench
[root@localhost mysql]# ./scripts/mysql_install_db ^C
[root@localhost mysql]# useradd mysql
[root@localhost mysql]# mkdir /data
[root@localhost mysql]# ls /data/
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
[root@localhost mysql]# yum install -y perl-XML-Dumper
已加載插件:fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base | 3.6 kB 00:00
epel/x86_64/metalink | 6.3 kB 00:00
epel | 4.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/3): epel/x86_64/updateinfo | 892 kB 00:00
(2/3): epel/x86_64/primary_db | 6.2 MB 00:00
(3/3): updates/7/x86_64/primary_db | 6.0 MB 00:01
Determining fastest mirrors
* epel: mirrors.ustc.edu.cn
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 perl-XML-Dumper.noarch.0.0.81-17.el7 將被 安裝
--> 正在處理依賴關系 perl(XML::Parser),它被軟件包 perl-XML-Dumper-0.81-17.el7.noarch 需要
--> 正在檢查事務
---> 軟件包 perl-XML-Parser.x86_64.0.2.41-10.el7 將被 安裝
--> 解決依賴關系完成

依賴關系解決

===========================================================================
Package 架構 版本 源 大小
===========================================================================
正在安裝:
perl-XML-Dumper noarch 0.81-17.el7 base 25 k
為依賴而安裝:
perl-XML-Parser x86_64 2.41-10.el7 base 223 k

事務概要
===========================================================================
安裝 1 軟件包 (+1 依賴軟件包)

總下載量:247 k
安裝大小:669 k
Downloading packages:
(1/2): perl-XML-Dumper-0.81-17.el7.noarch.rpm | 25 kB 00:00
(2/2): perl-XML-Parser-2.41-10.el7.x86_64.rpm | 223 kB 00:00
---------------------------------------------------------------------------
總計 840 kB/s | 247 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安裝 : perl-XML-Parser-2.41-10.el7.x86_64 1/2
正在安裝 : perl-XML-Dumper-0.81-17.el7.noarch 2/2
驗證中 : perl-XML-Dumper-0.81-17.el7.noarch 1/2
驗證中 : perl-XML-Parser-2.41-10.el7.x86_64 2/2

已安裝:
perl-XML-Dumper.noarch 0:0.81-17.el7

作為依賴被安裝:
perl-XML-Parser.x86_64 0:2.41-10.el7

完畢!
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
[root@localhost mysql]# yum install -y perl-Data-Dumper
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.ustc.edu.cn
正在解決依賴關系
--> 正在檢查事務
---> 軟件包 perl-Data-Dumper.x86_64.0.2.145-3.el7 將被 安裝
--> 解決依賴關系完成

依賴關系解決

===========================================================================
Package 架構 版本 源 大小
===========================================================================
正在安裝:
perl-Data-Dumper x86_64 2.145-3.el7 base 47 k

事務概要
===========================================================================
安裝 1 軟件包

總下載量:47 k
安裝大小:97 k
Downloading packages:
perl-Data-Dumper-2.145-3.el7.x86_64.rpm | 47 kB 00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安裝 : perl-Data-Dumper-2.145-3.el7.x86_64 1/1
驗證中 : perl-Data-Dumper-2.145-3.el7.x86_64 1/1

已安裝:
perl-Data-Dumper.x86_64 0:2.145-3.el7

完畢!
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
Installing MySQL system tables...2018-02-26 22:17:38 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-02-26 22:17:38 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-02-26 22:17:38 0 [Note] ./bin/mysqld (mysqld 5.6.36) starting as process 3050 ...
2018-02-26 22:17:38 3050 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-02-26 22:17:38 3050 [Note] InnoDB: The InnoDB memory heap is disabled
2018-02-26 22:17:38 3050 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-02-26 22:17:38 3050 [Note] InnoDB: Memory barrier is not used
2018-02-26 22:17:38 3050 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-02-26 22:17:38 3050 [Note] InnoDB: Using Linux native AIO
2018-02-26 22:17:38 3050 [Note] InnoDB: Using CPU crc32 instructions
2018-02-26 22:17:38 3050 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-02-26 22:17:38 3050 [Note] InnoDB: Completed initialization of buffer pool
2018-02-26 22:17:38 3050 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2018-02-26 22:17:38 3050 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2018-02-26 22:17:38 3050 [Note] InnoDB: Database physically writes the file full: wait...
2018-02-26 22:17:38 3050 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2018-02-26 22:17:38 3050 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2018-02-26 22:17:39 3050 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2018-02-26 22:17:39 3050 [Warning] InnoDB: New log files created, LSN=45781
2018-02-26 22:17:39 3050 [Note] InnoDB: Doublewrite buffer not found: creating new
2018-02-26 22:17:39 3050 [Note] InnoDB: Doublewrite buffer created
2018-02-26 22:17:39 3050 [Note] InnoDB: 128 rollback segment(s) are active.
2018-02-26 22:17:39 3050 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-02-26 22:17:39 3050 [Note] InnoDB: Foreign key constraint system tables created
2018-02-26 22:17:39 3050 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-02-26 22:17:39 3050 [Note] InnoDB: Tablespace and datafile system tables created.
2018-02-26 22:17:39 3050 [Note] InnoDB: Waiting for purge to start
2018-02-26 22:17:39 3050 [Note] InnoDB: 5.6.36 started; log sequence number 0
2018-02-26 22:17:39 3050 [Note] Binlog end
2018-02-26 22:17:39 3050 [Note] InnoDB: FTS optimize thread exiting.
2018-02-26 22:17:39 3050 [Note] InnoDB: Starting shutdown...
2018-02-26 22:17:41 3050 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2018-02-26 22:17:41 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-02-26 22:17:41 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-02-26 22:17:41 0 [Note] ./bin/mysqld (mysqld 5.6.36) starting as process 3072 ...
2018-02-26 22:17:41 3072 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-02-26 22:17:41 3072 [Note] InnoDB: The InnoDB memory heap is disabled
2018-02-26 22:17:41 3072 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-02-26 22:17:41 3072 [Note] InnoDB: Memory barrier is not used
2018-02-26 22:17:41 3072 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-02-26 22:17:41 3072 [Note] InnoDB: Using Linux native AIO
2018-02-26 22:17:41 3072 [Note] InnoDB: Using CPU crc32 instructions
2018-02-26 22:17:41 3072 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-02-26 22:17:41 3072 [Note] InnoDB: Completed initialization of buffer pool
2018-02-26 22:17:41 3072 [Note] InnoDB: Highest supported file format is Barracuda.
2018-02-26 22:17:41 3072 [Note] InnoDB: 128 rollback segment(s) are active.
2018-02-26 22:17:41 3072 [Note] InnoDB: Waiting for purge to start
2018-02-26 22:17:41 3072 [Note] InnoDB: 5.6.36 started; log sequence number 1625977
2018-02-26 22:17:41 3072 [Note] Binlog end
2018-02-26 22:17:41 3072 [Note] InnoDB: FTS optimize thread exiting.
2018-02-26 22:17:41 3072 [Note] InnoDB: Starting shutdown...
2018-02-26 22:17:43 3072 [Note] InnoDB: Shutdown completed; log sequence number 1625987
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/

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

[root@localhost mysql]# echo $?
0
[root@localhost mysql]# cp support-files/my-default.cnf /etc/my.cnf^C
[root@localhost mysql]# vim /etc/my.cnf
[root@localhost mysql]# ls
bin data include man mysql-test scripts sql-bench
COPYING docs lib my.cnf README share support-files
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# vi /etc/init.d/mysqld
[root@localhost mysql]# ls -l /etc/init.d/mysqld
-rwxr-xr-x 1 root root 10592 2月 26 22:30 /etc/init.d/mysqld
[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# chkconfig --list

註意:該輸出結果只顯示 SysV 服務,並不包含原生 systemd 服務。SysV 配置數據可能被原生 systemd 配置覆蓋。
如果您想列出 systemd 服務,請執行 ‘systemctl list-unit-files‘。
欲查看對特定 target 啟用的服務請執行
‘systemctl list-dependencies [target]‘。

mysqld 0:關 1:關 2:開 3:開 4:開 5:開 6:關
netconsole 0:關 1:關 2:關 3:關 4:關 5:關 6:關
network 0:關 1:關 2:開 3:開 4:開 5:開 6:關
[root@localhost mysql]# service mysqld start
Starting MySQL.Logging to ‘/data/mysql/localhost.localdomain.err‘.
.. SUCCESS!
[root@localhost mysql]# ps aux |grep mysql
root 3358 0.0 0.0 11776 1584 pts/0 S 22:33 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid
mysql 3495 5.6 10.8 1300792 453080 pts/0 Sl 22:33 0:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/tmp/mysql.sock
root 3523 0.0 0.0 112676 976 pts/0 S+ 22:34 0:00 grep --color=auto mysql
[root@localhost mysql]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1091/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1638/master
tcp6 0 0 :::3306 :::* LISTEN 3495/mysqld
tcp6 0 0 :::22 :::* LISTEN 1091/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1638/master
[root@localhost mysql]# killall 3358
-bash: killall: 未找到命令
[root@localhost mysql]# killall mysql
-bash: killall: 未找到命令
[root@localhost mysql]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
[root@localhost mysql]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1091/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1638/master
tcp6 0 0 :::22 :::* LISTEN 1091/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1638/master
[root@localhost mysql]#

九周第四次課(2月26日) 11.1 LAMP架構介紹 11.2 MySQL、MariaDB介紹 11.3/11.4/11.5 MySQL安裝 擴展 mysql5.5源碼編譯安裝