mysql>>
mysql>>
mysql>>
mysql>>
mysql>>
mysql>> (6)、查询表
desc ------------查询表
5、服务器端管理命令 -----------------DDL、DML、DCL
(1)DML
1)、insert -----------添加数据。
格式:INSERT [INTO] tbl_name [(col_name,...)] {VALUES | VALUE} (value1,value2,...),(...),...
注意,向表中插入的是【字符串】,需用【引号引用】,如果向表中插入的是数字,不能用引号引用。
例:
mysql> insert into students value (1,'little',17,23,'M');
mysql> insert into students (ID,Name,Classes) values (2,'Zhang Sanfeng',"Wudang"),(3,'Zhang Wuji',"Mingjiao");
mysql> select * from students; ------------查询
2)、select ----------单表查询
mysql> select * from TAB_NAME ------------查看表的所有字段
mysql> select>
mysql> select> mysql> select * from TAB_NAME where clause ------------选择
操作符:LIKE -------------模糊匹配
RLIKE ------------使用正则表达式对字符串进行模式匹配
IS NULL/IS NOT NULL -------------判断指定字段是否为空
mysql> select * from students where Age < 40;
mysql> select * from students where Age is null;
mysql> select * from students where Name like '%ang%';
mysql> selcet * from students where rlike '^Z.*g$' -----------查找较慢
mysql> select * from TAB_NAME order by age desc ---------------排序
3)、update --------------修改表的数据
mysql> update students set age=age-10 where sex is not null;
mysql> select * from students where> mysql> update students set age=age+5;
mysql> update students set age=age-10 where gender is not null;
mysql> update students set age=age-20 order by age desc limit 5;
4)、delete -------------删除表数据。需进行限定,防止全表删除。
mysql> delete from students where Age > 50;
mysql> delete from students where Age delete from students where age delete from students order by> 5)、mysql> use mysql ------------使用表
(2)、DCL
1)、GRANT ----------授权(查看、删除等)
mysql> grant select ON ysu.students to 'little'@'172.16.%.%'>
mysql> grant delete ON ysu.students to 'little'@'172.16.%.%'> 2)、REVOKE ----------回收权限
mysql> flush privileges;------------手动重读授权表,使授权生效
php 与 php-fpm不能共存
6、LAMP平台快速架构(httpd、php模块化通信) -------------项目
(1)、安装软件包
CentOS 7:yum install httpd php php-mysql mariadb-server
CentOS 6:yum install httpd php php-mysql mysql-server
(2)、创建虚拟主机
(3)、创建用于测试的账户 ----------------在MySQL或MariaDB中
mysql> create database wpdb;
mysql> grant all on wpdb.* to 'wpuser'@'172.16.%.%'> (4)、测试php,测试php和mysql之间的通信,将以下源代码复制到以【index.php为文件名】的主页文件中。
测试php:
测试mysql连接性:
(5)、将某个应用复制到虚拟主机的文档根目录中,进行进一步测试。
三、编译安装AMP ----------httpd2.4、Meriadb
1、编译安装httpd2.4
例:编译安装httpd-2.4.27
(1)、编译安装apr
# tar xf apr-1.5.2.tar.gz
# cd apr-1.5.2
# ./configure --prefix=/usr/local/apr152
# make -j #
# make install
(2)、编译安装apr-util
# tar xf apr-util-1.5.4.tar.gz
# cd apr-util-1.5.2
# ./configure --prefix=/usr/local/apr-util154 --with-apr=/usr/local/apr152
# make -j #
# make install
(4)、编译安装httpd-2.4.27
# tar xf httpd-2.4.27.tar.gz
# cd httpd-2.4.27
# ./configure --prefix=/usr/local/apache24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork --with-pcre --with-zlib --with-apr=/usr/local/apr152 --with-apr-util=/usr/local/apr-util154
# make -j #
# make install
(5)、导出
1)、导出二进制文件:--------防止二进制不兼容
创建/etc/profile.d/httpd24.sh
export PATH=/usr/local/apache24/bin:$PATH
2)、导出帮助文档(可选)
编辑/etc/man.config
MANPATH /usr/local/apache24/man
3) 导出头文件:
# ln -sv /usr/local/apache24/include/ /usr/include/httpd
(6)、如果想要使用service命令来启动或关闭服务,则需要为httpd提供sysV风格的脚本,脚本内容如下:/etc/init.d/httpd
注意:想要成功使用该脚本管理服务,要在/etc/httpd24/httpd.conf配置文件中添加以下指令:PIDFile "/var/run/httpd24.pid"
#!/bin/bash
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd24/httpd.conf
# config: /etc/sysconfig/httpd24
# pidfile: /var/run/httpd24.pid
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd24 ]; then
. /etc/sysconfig/httpd24
fi
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache24/bin/apachectl
httpd=${HTTPD-/usr/local/apache24/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd24.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
start() {
echo -n $"Starting $prog: "
LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not>
failure $"not> else
killproc -p ${pidfile} $httpd -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;