PHP-20131110-php连接数据库
原创woxuewangluo 博主文章分类:APP运维文档 ©著作权
©著作权归作者所有:来自51CTO博客作者woxuewangluo的原创作品,请联系作者获取转载授权,否则将追究法律责任
1、mysql建用户并授权:
创建用户:
mysql> create user test identified by 'w123123';
Query OK, 0 rows affected (0.16 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| #mysql50#bin-log |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.14 sec)
为用户授权:
mysql> grant all privileges on test.* to test@localhost identified by 'w123123';
Query OK, 0 rows affected (0.00 sec)
mysql> use test;
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| a |
| mrg |
| t1 |
| t2 |
+----------------+
4 rows in set (0.01 sec)
查看要连接的数据库中表的数据情况:
mysql> select * from t1;
Empty set (0.06 sec)
mysql> select * from t2;
+---+
| a |
+---+
| 1 |
| 2 |
| 3 |
+---+
3 rows in set (0.05 sec)
mysql>
2、PHP连接数据库编码:
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章