搭建LAMP环境(源码方式)(4)

--1.修改root用户密码,创建测试数据库和表
[root@serv02 bin]# ./MySQL
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.58-log Sourcedistribution
 
Copyright (c) 2000, 2010, Oracle and/or itsaffiliates. All rights reserved.
This software comes with ABSOLUTELY NOWARRANTY. This is free software,
and you are welcome to modify andredistribute it under the GPL v2 license
 
Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
 
mysql> set password=password("helloworld");
Query OK, 0 rows affected (0.00 sec)
 
mysql> exit
Bye
[root@serv02 bin]# ./mysql -uroot-phelloworld
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.58-log Sourcedistribution
 
Copyright (c) 2000, 2010, Oracle and/or itsaffiliates. All rights reserved.
This software comes with ABSOLUTELY NOWARRANTY. This is free software,
and you are welcome to modify andredistribute it under the GPL v2 license
 
Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
 
mysql> use larry
Database changed
mysql> show tables;
+-----------------+
| Tables_in_larry |
+-----------------+
| t_log          |
| t_user          |
+-----------------+
2 rows in set (0.00 sec)
 
mysql> select * from t_user;
+----+----------+
| id | name    |
+----+----------+
|  1 |larrywen |
|  2 |justdb  |
|  3 |wgb      |
+----+----------+
3 rows in set (0.00 sec)
 
--2.新建测试php文件
 
[root@serv02 php5]# cd/usr/local/apache/htdocs/
[root@serv02 htdocs]# vim index.php
[root@serv02 htdocs]# cat index.php
<?php
      phpinfo();
?>
[root@serv02 htdocs]# vim user_list.php
[root@serv02 htdocs]# pwd
/usr/local/apache/htdocs
[root@serv02 htdocs]# vim user_list.php
[root@serv02 htdocs]# cat user_list.php
<?php
      $conn=mysql_connect("localhost","root", "helloworld");
      mysql_select_db("larry",$conn);
      $users=mysql_query("select* from t_user");
 
      while(!!$user=mysql_fetch_array($users)){
              echo$user["id"]."------->".$user["name"]."<br>";   
      }
      mysql_close();
?>
[root@serv02 htdocs]#
 
--3.浏览器输入,如果出现php相关的配置信息,则证明配置成功。输入,如果能出现以下的信息,则证明PHP、MySQL、Apache整合成功。
 
1------->larrywen
2------->justdb
3------->wgb

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/45f0c23677b995a6f75e2091fa2ebba9.html