一、mysql 创建数据库 mysql密码,默认没有 如果想更改的话, mysqladmin -uroot password root123 登录 : [[emailprotected] root]# mysql -uroot -proot123 1、......
mysql>Database changed
mysql> exit
[[email protected] html]# vi root.sql
效果如下: (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;
->);
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