linux php mysql 查询,15、sql语句集,Linux 下PHP查询mysql

一、mysql 创建数据库 mysql密码,默认没有 如果想更改的话, mysqladmin -uroot password root123 登录 : [[emailprotected] root]# mysql -uroot -proot123 1、......

mysql>Database changed

mysql> exit

[[email protected] html]# vi  root.sql

424a3daeb81d50acf3cfc5ff067666c1.png

效果如下:     (3,"英语");

登录   : [[email protected] root]#   mysql    -uroot    -proot123    );

一、mysql 创建数据库grant   all   on   book.*   to   [email protected]   identified   by   "lili123" ;

mysql> create   table   book(

如果想更改的话, mysqladmin  -uroot   password  root123mysql> exit;

af43b28db13a09bede51bc17f8856b1c.png    ->);

4、创建book表,添加数据Enter password:       (这里输密码)

7、查询表

mysql_connect(NULL,"lili","lili123","localhost");

mysql_selectdb("book");

$sql="select * from book";

$res=mysql_query($sql);while($row=mysql_fetch_row($res)){

print"$row[0] $row[1]
";

}

$a=array("阳光","沙滩","海浪","仙人掌");for($i=0;$i<4;$i++){

print"$a[$i]
";

}?>

[[email protected] html]#  cat  >  lili.sql

如果想要网格线Your MySQL connection id is 5 to server version: 3.23.54

-> (1,"语文"),

mysql> use  book;    (先确定要操作的数据库)Query OK, 0 rows affected (0.08 sec)| id | name   |

mysql>  grant   all   on   book.*   to   [email protected]   identified   by   "lili123";

|  2 | 数学 |

[[email protected] html]#   mysql   -u   lili    -p+----+--------+

Records: 3  Duplicates: 0  Warnings: 0Bye    name   char(20)   not  null,

mysql密码,默认没有    id   int   not   null,

5、创建book表Query OK, 1 row affected (0.08 sec)

[[email protected] html]# mysql   -u   root   -p  

+----+--------+    -> name   char(20)   not   null,

3、lili登录

创建lili用户

1、创建book数据库

二、在 /var/www/html  中 创建index.php

mysql>   create   database   book;    -> (3,"英语");

)Enter password:Query OK, 0 rows affected (0.06 sec)    -> (2,"数学"),

|  3 | 英语 |

在浏览器输入    ,  结果如下:|  1 | 语文 |

mysql> select   *   from   book;

mysql>  insert   into   book   values

退出mysql

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the buffer.Welcome to the MySQL monitor.  Commands end with ; or \g.

(1,"语文",),Enter password:

[[email protected] html]# mysql   -u   lili   -p  

primary   key(id)

[[email protected] html]#  vi    index.phpuse   book;Query OK, 3 rows affected (0.00 sec)

2、授权给 lili 用户

mysql_connect(NULL,"lili","lili123","localhost");

mysql_selectdb("book");

$sql="select * from book";

$res=mysql_query($sql);

print (‘

print (‘

‘);for($i=0;$i<3;$i++){

print"

$row[$i]";

}

print (‘

‘);

}

print (‘

‘);

$a=array("阳光","沙滩","海浪","仙人掌");for($i=0;$i<4;$i++){

print"$a[$i]
";

}?>

15、sql语句集,Linux 下PHP查询mysql

6、添加数据create   table   book(

(2,"数学"),

create   database   book;

+----+--------+    -> primary   key(id)    -> id   int   not   null,Bye insert   into  book  values

(注意:上面操作也可以用sql语句集来执行:   (好处是,去别的机子也可以执行sql语句集 就行,不用从头打过)

原文标题:15、sql语句集,Linux 下PHP查询mysql

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值