>  기사  >  데이터 베이스  >  mysql数据库用户权限问题

mysql数据库用户权限问题

WBOY
WBOY원래의
2016-06-07 15:27:291169검색

修改root密码 mysql USE mysql; #切换到 mysql DB Database changed mysql SELECT User, Password, Host FROM user; #查看现有用户,密码及允许连接的主机 --------------------------- | User | Password | Host | --------------------------- | root | | l

修改root密码
mysql> USE mysql;                    #切换到 mysql DB

Database changed

mysql> SELECT User, Password, Host FROM user;            #查看现有用户,密码及允许连接的主机

+------+----------+-----------+
| User | Password | Host      |
+------+----------+-----------+
| root |          | localhost |
+------+----------+-----------+
1 row in set (0.00 sec)

mysql> update user set password=PASSWORD('123456') where user='root';           #更新root的用户密码

Query OK, 0 rows affected (0.00 sec)

Rows matched: 1  Changed: 0  Warnings: 0

mysql> flush privileges;                                                          #刷新

Query OK, 0 rows affected (0.00 sec)
mysql> grant all on *.* to root@localhost;                             #给root@localhost用户管理所有数据库密码的权限
Query OK, 0 rows affected (0.00 sec)

mysql> flush tables;                                                              #刷新
Query OK, 0 rows affected (0.00 sec)

mysql>

mysql> grant all on *.* to root@“%”;                             #%的ip都能远程访问root用户管理所有数据库密码的权限
Query OK, 0 rows affected (0.00 sec)

mysql> flush tables;                                                              #刷新
Query OK, 0 rows affected (0.00 sec)

mysql>

mysql> show grants for 'root'@'%';
+------------------------------------------------------------------------------------------------------------------+
| Grants for root@%                                                                                            |
+------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root‘@'%' IDENTIFIED BY PASSWORD '*ACAAE9E2C384B05A750FB998F83C9E13D5F716A5' |
| GRANT ALL PRIVILEGES ON `mstr`.* TO 'root'@'%'                                                               |
+------------------------------------------------------------------------------------------------------------------+

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.