摰鋆摰Mysql 敺閮剖 :
4 ~) {7 I" @ F9 e脖甇亥身摰 MySQL( E) ?2 B+ y$ L# E0 r- J
A.5 x7 `3 G: R* S' R9 D
閮剖php.ini(/etc/php.ini)
- c' p; L* e$ p1 jphp.ini
3 i* r k' h$ c& ^# j# x' k1 memory_limit = 128M //PHP舐刻園銝3 N2 t, b Z+ E" e# O# k1 [
2 display_errors = Off //憿舐內航炊閮
$ r; M/ }4 O7 q/ `- v, e3 date.timezone = Asia/Taipei //(銵閬閮剖嚗銝賀HP雿輻典唳賣豢航炊閮)
$ q* d/ e3 C( p5 ~$ P: h' X4 D" J4 session.cookie_lifetime = 0 //session摮瘣餅(桐蝘嚗0隞銵典瘣餉喟閬賢券)
. q0 G9 q" r9 `1 Y& o8 g. E) u5 x# V4 H1 L1 r
B.
3 m, f8 f/ Y1 ?& S: S$ t閮剖my.cnf(/etc/my.cnf). h5 Y6 ^/ B9 [
my.cnf :
+ h7 E, [% ^! l( n( k1 log-error=/var/log/mysqld.log //亥摮曆蝵" W+ @! p% p' K3 J6 F `
2 connect_timeout = 15 //蝺timeout
3 g% k C, K6 ~) R/ M7 P- `7 _% [5 P3 max_connections = 3000 //憭折蝺
* `0 ]# Z( S- I1 [4. service mysqld restart$ F+ } }# c- _: e
* J: w r6 Q- U5 c( P9 a3 P
! k# Q. r1 g$ w- O! E: YC.
- }( s" ^0 x/ ^5 x, ^閮剖 MySQL 鞈摨怎恣 root 撣單嗥撖蝣潘瑁sudo mysql_secure_installation嚗隞雿摨銝撟曆辣鈭( p+ c9 m% M. A4 V- j
1. Enter current password for root (enter for none): // 湔交 Enter嚗粹閮剜撖蝣
9 Q0 g2 A- w# ~! A% k3 x2. Set root password? [Y/n] //頛詨 Y 靘閮剖撖蝣
9 Z# f, x- c, r5 h3. New password: // 頛詨 root 啣蝣
* W8 i9 \0 b" v3 F6 }5 W6 A8 ~4. Re-enter new password: // 銝甈∟撓 root 啣蝣
! q& c- G6 p/ F8 e3 T0 M3 `' k% Z" H5. Remove anonymous users? [Y/n] //閮 Yes 嚗湔交 Enter G$ T; T6 ]7 }: `% b7 n0 F
6. Disallow root login remotely? [Y/n] //閮 Yes 嚗湔交 Enter
) r/ ^& o: T. o, w9 Z0 S8 c1 ]7. Remove test database and access to it? [Y/n] //閮 Yes 嚗湔交 Enter$ c. R0 l; f6 v" ~/ Y, X: y/ J
8. Reload privilege tables now? [Y/n] //閮 Yes 嚗湔交 Enter! Z- y/ J4 s4 s( W; a3 ?- L/ J' ]+ W
0 _8 G* w! k- M, A# M7 q; l& X; t, r/ b2 z U
亥拍典閮剖 root 撖蝣潛餃 MySQL嚗瑁sudo mysql -u root -p嚗撖蝣潭迤蝣箏停脣乓mysql>璅蝷箇泵
# g- j% n) \7 ~( M) G4 e) \. M 瑁豢閬券鞈摨
* t% A$ p' P! a. H8 U) @* F; pmysql> use mysql
+ @" z6 u" F9 y! x5 ~5 }0 w) r( D/ |2 T* ^
瑁select host,user from user ;閬蝯撠暹瑁, B! D2 y9 e0 U, n9 q
mysql> select host,user from user ; ]! B4 v( n! W8 L8 Q* K/ O9 n
+-----------+------+* _5 ?0 }& H" B" d) L: i) S$ `' u
| host | user |
5 O. [+ Y, s; ]# T2 V' q! s, n+ F$ I) \+-----------+------+& h7 {- J& W D, h# I. E
| 127.0.0.1 | root |
! N& ?5 @+ U$ j# v| localhost | root |% L+ a$ v& X, g) g1 n4 f- g
+-----------+------+
# n+ |. C4 g: v2 rows in set (0.00 sec)
; @6 \+ p# K4 I) c( u- E0 w c, b! T- }$ D
啣銝雿輻刻
. B- V+ `0 R8 oinsert into user (host,user,password) values ('%','your_account',password('your_password'));! U% d3 a, G' m3 ~ o+ x2 ], |4 Q
: [( h. j0 o+ W; N
餅閰脖蝙刻蝞∠甈嚗璅雿賣颲行蝡航 嚗 root 蝡舐餃亥◤鈭嚗
0 j0 Q$ Z8 r0 e. g' mGRANT ALL ON *.* TO 'your_account'@140.112.1.1 IDENTIFIED BY 'your_password' WITH GRANT OPTION;) y4 J' X2 D5 q# D
銝嗅撣唾嚗芣臭祈摨思蝙刻撣唾嚗銝瘝隞颱甈* f0 s& N9 { Y1 A& b6 R: U! B C4 N( b
餉閮剖4 c+ ?" T& N/ Z3 U( S% P
FLUSH PRIVILEGES;
7 T$ E# o/ c; T4 ^. s/ x7 t摰鋆摰Phpmyadmin ,run http://www.domain.com/dbadmin show error : The mbstring extension is missing. Please check your PHP configuration.
# `' D, _) i) @隢摰鋆" q4 g8 ~1 A" q' }, m* q( |
& W4 W6 ?3 M& v1 \: zyum -y install php-mbstring
3 A3 s& |- G8 ~
% M5 _* ^, o: r; c! Y% ]& H, W% D亙箇曄撩撠mcrypt嚗隢摰鋆
+ m7 J7 z$ ?' M2 x( `, n6 [ $ L- w0 W& j4 N# O) `; H6 B
yum -y install mcrypt
) @' v. G# A7 \9 |9 Q( p0 i( x" iservice nginx restart
9 d) M& U9 ~8 Q- L0 iLogin phpadmin 敺箇 error:蝻箏 mysqli 游憟隞嗚隢瑼X PHP 閮剖Solution:
( _$ i" Z0 Q) U$ Gphp -m | grep mysqli ===> confirm mysqli module is installed
( L. G/ @& v1 Q! h5 {. @7 W2 Kphp -i | grep extension_dir ===> 撠曉辣隡貊桅# H' d4 b( y% z( |7 p. [6 Y8 Q
yum -y install php-mysql ( yum install php5-mysqli) ===> ok
/ z( D' `% K9 l" ~# J2 j蝻箏 mcrypt 游憟隞嗚隢瑼X PHP 閮剖) x U) d/ `% ]7 v' l1 I" X* j" S5 F
yum install php-mcrypt& `4 O3 x4 u6 G9 l! V
yum install libmcrypt libmcrypt-devel ===> ok
6 Q* \5 c5 w. ` V0 T
1 H8 B% u; [" }+ s( _# T& [. z# ?0 [& O- |' n, l) _
|
|