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连接数据库编码:

阅读 评论 收藏 转载 喜欢 打印举报
已投稿到:
  • 评论加载中,请稍候...
发评论

       

    验证码: 请点击后输入验证码 收听验证码

    发评论

    以上网友发言只代表其个人观点,不代表新浪网的观点或立场。