马哥教育 mysql_马哥教育第二十三MySQL基础应用入门

查看support-files目录下支持文件根据不同内存大小选用不同配置文件(my-small.cnf、my-large.cnf、my-huge.cnf、my-innodb-heavy-4G.cnf)sql数据类型:字符型:固定字符型char、可变长度varchar数值型:精确数值型:int、近似数值型:float、double日期型:date、time、datetime、year(4)、year(2)内置型:enum、set类型修饰:null、not null、default数值型:unsigned:无符号整数:auto_incrementddl:caeate {database,table,user}、drop、alter、grant、revokedml:insert、delete、update、select数据库语句:create datebases db_name;drop datebases db_name;show databases;create tables [db_name.]tb_name(字段1 字段类型或修饰类型,字段2 字段类型或修饰类型,......);drop tables tb_name;desc tb_name;显示表的结构create user test@'192.168.%.%' identified by '123456';%表示任意长度任意字符;_匹配任意长度单个字符;mysql -utest -p:本地连接mysql -utest -h 192.168.146.138 -p:远程连接drop user test@'192.168.%.%';grant all on testphp.* to test@'192.168.%.%';授权grant all on testphp.test to test@'192.168.%.%';授权单表all 表示所有权限。db_name *表示所有库。tb_name *表示所有表。flush privileges; 授权立即生效。revoke all on testpho.* from test@'192.168.%.%';insert into pw_userapp values(1,12321,xj,123,343);插入数据2、MySQL基础应用及编译LAMPdelete from pw_userapp;select * from pw_userapp;select user,host,password from user where user='root' order by host desc;倒序查找数据update pw_userapp set user='test' where id='3';BETWEEN start_value AND end_value;LIKE: 模糊匹配:Name LIKE O%;rlike:支持正则表达式;select user,host,password from mysql.user where user rlike '^p' order by host desc;mysql常用的show命令show engines;查询mysql存储引擎。show table status \G:查看当前库中标的详细信息,不需要使用分号结尾show character set;显示字符集show collation;显示字符集排序规则show global variables;mysql各种工作属性是通过其服务器变量来定义的:show global variables like '%wait_timeout%';查看单个变量中的值show global status;显示数据库中所有状态统计数据show global status like '%Uptime%';显示统计单个变量数据编译安装php2.6(httpd和php在同一台服务器上安装配置)请配置好yum源(系统安装源及epel源)后执行如下命令:yum -y groupinstall "Desktop Platform Development"yum -y install bzip2-devel libmcrypt-devel./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-maintainer-zts参数说明:--prefix=/usr/local/php:安装路径--with-mysql=/usr/local/mysql:编译使用mysql驱动指明路径,如果是rpm包安装的mysql只需写--with-mysql--with-openssl: --with-mysql的加密工具--with-mysqli=/usr/local/mysql/bin/mysql_config:php访问mysql的另外一种机制--enable-mbstring:多字节字串,如果想支持中文这个选项是必须--with-freetype-dir:字体处理工具,php显示网页可以对字体加工。--with-jpeg-dir :jpeg图片生成工具--with-png-dir:png图片生成工具--with-zlib:压缩库--with-libxml-dir=/usr:指明需要使用的xml库所在位置,--enable-xml:启用xml功能--enable-sockets:支持sockets方式进行通信--with-apxs2=/usr/local/apache/bin/apxs:apxs2为http函数用于编译http第三方模块,如果需要把php编译成模块就必须说明,模块编译函数在那里。--with-mcrypt:支持使用加密库--with-config-file-path=/etc:在etc下创建主配置文件php.ini--with-config-file-scan-dir=/etc/php.d:支持主配置文件以外在php.d下的以.ini结尾子配置文件,--with-bz2:支持bz2压缩--enable-maintainer-zts:如果http编译时指明event、worker这项就必须添加,如果:frefork模式这项不能添加。这里为了支持apache的worker或event这两个MPM,编译时使用了--enable-maintainer-zts选项。如果使用PHP5.3以上版本,为了链接MySQL数据库,可以指定mysqlnd,这样在本机就不需要先安装MySQL或MySQL开发包了。mysqlnd从php 5.3开始可用,可以编译时绑定到它(而不用和具体的MySQL客户端库绑定形成依赖),但从PHP 5.4开始它就是默认设置了。./configure --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd为php提供配置文件:cp php.ini-development /etc/php.ini:开发环境可以使用此配置文件cp php.ini-production /etc/php.ini:生产环境用此配置文件编辑httpd配置文件,让httpd支持php模块:vim /etc/httpd/httpd.conf :http主配置文件。添加如下二行:AddType application/x-httpd-php  .phpAddType application/x-httpd-php-source  .phps定位至DirectoryIndex index.html :DirectoryIndex  index.php  index.html重新启动httpd,或让其重新载入配置文件即可测试php是否已经可以正常使用。测试页面index.php示例如下:<?php $link = mysql_connect('127.0.0.1','root','mageedu');if ($link)echo "Success...";elseecho "Failure...";mysql_close();?>

3、php-fpm模式下的LAMP

在httpd2.4版本中查看服务器状态页面需要添加

SetHandler server-status

Require all granted

fpm安装php(php单独运行不以模块方式运行)tar xf php-5.6.9.tar.bz2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值