读万卷书行万里路

mysql密码修改,创建远程用户记录

发布时间:2018/3/5 14:12:48
    全文约194
    预计需要1分钟

方法1: 用SET PASSWORD命令

  mysql -u root

  mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

方法2:用mysqladmin

  mysqladmin -u root password "newpass"

  如果root已经设置过密码,采用如下方法

  mysqladmin -u root password oldpass "newpass"

方法3: 用UPDATE直接编辑user表

  mysql -u root

  mysql> use mysql;

  mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';

  mysql> FLUSH PRIVILEGES;

丢失root密码

  mysqld_safe --skip-grant-tables&

  mysql -u root mysql

  mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';

  mysql> FLUSH PRIVILEGES;

创建远程用户并授权

创建用户

create user test identified by '123456';

远程授权

 grant all privileges on *.* to 'test'@'%'identified by '123456' with grant option;
# grant all privileges on database.table to user@ip identified by password with grant option;

刷新权限

flush privileges ;

开启Linux 防火墙

iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT     #允许 3306  端口

service iptables save
目录
文章作者:CavinHuang
文章链接:http://blog.zukmb.cn/posts/3f13de63/
版权声明:转载请注明来自CavinHuangのBlog
正则表达式解析一个完整的url
常见的js算法面试题收集,es6实现版