摰鋆摰Mysql 敺閮剖 :* q: v! N0 V6 M0 h
脖甇亥身摰 MySQL
' r0 s7 L8 B' l$ ]5 yA.
. j& I& ~2 E# u# W- q8 s& W閮剖php.ini(/etc/php.ini)' @- [ E& p- R& B/ |; k! i! F
php.ini1 @2 L3 h V8 q2 J/ b% |1 M$ f
1 memory_limit = 128M //PHP舐刻園銝, ]9 r6 j. s% f- r: S
2 display_errors = Off //憿舐內航炊閮
8 F% I0 i7 y5 L; k; Q- I3 date.timezone = Asia/Taipei //(銵閬閮剖嚗銝賀HP雿輻典唳賣豢航炊閮)) H4 i: H* k$ i! q& D9 g" j p9 o/ m
4 session.cookie_lifetime = 0 //session摮瘣餅(桐蝘嚗0隞銵典瘣餉喟閬賢券)
+ d# P5 l4 S: m4 Q
. O/ @7 |+ j) k- s; d ^/ @- d# NB.
8 }! k+ T% S% @6 B( o+ U0 V6 S- p閮剖my.cnf(/etc/my.cnf)
, M" g2 I! p$ c* mmy.cnf : # K' q/ H! L2 k% a
1 log-error=/var/log/mysqld.log //亥摮曆蝵
* m( \/ h9 h) U. g2 d" F; K% _" n2 connect_timeout = 15 //蝺timeout
9 y; g: h; n; n/ z3 max_connections = 3000 //憭折蝺0 w4 Y) A2 |; P" `& q) U# L
4. service mysqld restart# b5 d* E0 l( w: _; ?
; f& z7 z, J7 `' o; J& L9 k* E3 D
t* ]* }9 H8 s( v1 M% h/ ]) `
C.0 f: S9 j" l! i' F" F) a) X
閮剖 MySQL 鞈摨怎恣 root 撣單嗥撖蝣潘瑁sudo mysql_secure_installation嚗隞雿摨銝撟曆辣鈭8 N! r9 N8 `+ J5 B3 m0 w& [. {2 h
1. Enter current password for root (enter for none): // 湔交 Enter嚗粹閮剜撖蝣
p7 m9 ?6 d1 b) g A2. Set root password? [Y/n] //頛詨 Y 靘閮剖撖蝣
u3 l3 l" ]& b# z7 l$ j( y6 k y5 ~ S3. New password: // 頛詨 root 啣蝣+ b8 u8 L( x3 G& E3 f
4. Re-enter new password: // 銝甈∟撓 root 啣蝣
8 q& X# t p. p5 ?5. Remove anonymous users? [Y/n] //閮 Yes 嚗湔交 Enter9 l+ V' k6 ~' L9 K; ?
6. Disallow root login remotely? [Y/n] //閮 Yes 嚗湔交 Enter
. l2 ?: R+ m4 K7 b7. Remove test database and access to it? [Y/n] //閮 Yes 嚗湔交 Enter
0 k9 |1 i: g+ q* B0 f" P/ V8. Reload privilege tables now? [Y/n] //閮 Yes 嚗湔交 Enter2 i* b Y0 ~7 x! D; n- U: g3 r
" I d* D u5 v, P8 m1 t, s: L6 e9 H* G3 u% |
亥拍典閮剖 root 撖蝣潛餃 MySQL嚗瑁sudo mysql -u root -p嚗撖蝣潭迤蝣箏停脣乓mysql>璅蝷箇泵. v) Q5 `9 S% \
瑁豢閬券鞈摨# U; M5 R( q+ x/ w6 f, q( O+ R! |
mysql> use mysql, [" r* h, Y0 p8 W6 t" B; d5 [ x
/ Q& h0 o3 X! E/ `6 d4 Y% w: \6 ?# d 瑁select host,user from user ;閬蝯撠暹瑁
! r9 m3 Z6 W3 _" j Omysql> select host,user from user ;, L$ Y+ W% l4 k
+-----------+------+- {+ P" A$ g# J
| host | user |6 @# a/ x. H u& H
+-----------+------+
2 F. P0 p: e. k$ j7 U| 127.0.0.1 | root |
3 u8 X# M9 e* S' j| localhost | root |9 |4 F9 k3 {+ ?- k" [3 x
+-----------+------+
, v8 b( a$ Q; A& A% {7 ^2 rows in set (0.00 sec)
% V8 R4 A4 ?0 f: x& K I& c* E7 @( m5 I4 J. |. ]: K0 z
啣銝雿輻刻& L3 W! f2 ?. A, G1 y7 c! S/ n
insert into user (host,user,password) values ('%','your_account',password('your_password'));) t0 o" i+ l" S
4 n6 t. Q1 n* Z餅閰脖蝙刻蝞∠甈嚗璅雿賣颲行蝡航 嚗 root 蝡舐餃亥◤鈭嚗 2 P+ h1 ?! A5 q2 k, F0 }
GRANT ALL ON *.* TO 'your_account'@140.112.1.1 IDENTIFIED BY 'your_password' WITH GRANT OPTION; l' u4 Y) ^& v1 a
銝嗅撣唾嚗芣臭祈摨思蝙刻撣唾嚗銝瘝隞颱甈
6 ~: l/ t0 N* D9 H5 [9 F, U: N餉閮剖
! @! q; o& v0 f: {$ W: zFLUSH PRIVILEGES;
$ V' U* y/ h9 Q0 h- `) {0 _: H摰鋆摰Phpmyadmin ,run http://www.domain.com/dbadmin show error : The mbstring extension is missing. Please check your PHP configuration.
2 Y7 Q" k2 B3 s7 W' i4 @7 K隢摰鋆
" c! ^- c) s& ~" q. u2 l
8 z F9 Y# j; ?$ Y; z- ryum -y install php-mbstring
" w2 p, k8 B6 m G4 {7 \8 _# E( C( `. F D+ l _+ S0 p3 G
亙箇曄撩撠mcrypt嚗隢摰鋆. G+ q! h7 H# I8 I& ]! f+ y
( o3 L, w- X3 S6 g0 r. eyum -y install mcrypt* H+ C e7 }" O9 ` d! ~* X! P3 W
service nginx restart# v5 S6 \ K/ G# A* s! ^' B0 m
Login phpadmin 敺箇 error:蝻箏 mysqli 游憟隞嗚隢瑼X PHP 閮剖Solution:
8 n% ^3 f. j9 vphp -m | grep mysqli ===> confirm mysqli module is installed
0 E- R- A7 V {$ B/ K. H W0 ~php -i | grep extension_dir ===> 撠曉辣隡貊桅* b. h. @' R( D' a% [3 `) O. b
yum -y install php-mysql ( yum install php5-mysqli) ===> ok
$ i2 ~1 \+ k+ C9 I9 V蝻箏 mcrypt 游憟隞嗚隢瑼X PHP 閮剖! U$ E& [( u7 X
yum install php-mcrypt
6 Y }" N% v5 fyum install libmcrypt libmcrypt-devel ===> ok
6 v/ R r) t1 O( W k. |6 d1 N$ N8 u7 E8 B! r6 \# n% @2 n
; \2 A8 h5 ~9 v+ |) v |
|