分享

Mysql修改用户名、密码,并别的电脑访问到本机MySql数据库

 dabinglibrary 2014-06-20
修改用户名:
mysql> use mysql;  选择数据库
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set user="deve" where user="root";    将用户名root改为deve
Query OK, 4 rows affected (0.12 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges;    刷新权限
Query OK, 0 rows affected (0.04 sec)

修改密码:

1.直接在数据库中修改记录

mysql> use mysql
mysql> update user set password = password(”new_password”) where user = “user_name”;
mysql> flush privileges;
其实这种方法就是更新一条数据库记录,与普通update语句不同的是,密码加密存储,需用password()函数来生成,另一个不同点是需要刷新权限表。

2.在数据库中运行set password
mysql> set password for user_name = password(”new_password”);
mysql> flush privileges;
同第一种方法,也要刷新权限表


让别的电脑访问到本机MySql数据库:

grant all on *.* to 'deve'@'%' identified by 'deve'; 第一个deve表示别的电脑连接是需要用到的用户名,第二个deve表示别的电脑连接时用的密码。%表示给所有用户权限。

如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码 
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword'.

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多