Mysql修改密码,远程登录,ERROR 1044 (42000)错误解决办法

mysql修改root密码  

第一步:用帐号登录mysql

[root@CentOs5 ~]# mysql -u root
 
第二步:改变用户数据库
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
 
第三步:修改密码,记得密码要用password()函数进行加密,一定不要忘记!!!
mysql> update user set password=password('qwe123') where user='root';
Query OK, 1 row affected (0.04 sec)
Rows matched: 1  Changed: 1  Warnings: 0
 
第四步:刷新权限表
mysql> flush previleges;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘previleges’ at line 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
第五步:退出mysql
mysql> quit
Bye
 
第六步:对mysql进行重启
[root@CentOs5 ~]# service mysqld restart;
STOPPING server from pid file /var/run/mysqld/mysqld.pid
100421 13:44:03  mysqld ended
Stopping MySQL:                                            [  OK  ]
Starting MySQL:                                            [  OK  ]
[1]+  Done                    mysqld_safe –skip-grant-tables

mysql数据库远程连接开启方法  

登陆MYSQL
mysql  -u root -p
进入mysql库
mysql> use mysql;
查询user表下的几个字段的内容
mysql>   select host,user,password from user;
MySQL>select host, user from user; 
mysql> update user set host = '%' where user = 'root';
MySQL>update user set host = '%' where user = 'root';
mysql> grant all privileges  on *.* to root@'%' identified by "root";
FLUSH PRIVILEGES;


/etc/mysql/my.cnf
mysql  内127.0.0.1  改为 外网IP
=======================================================
mysql> source /tmp/haobangshou_20140820000101.sql                   导入sql

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'  

方法一:
1.关闭mysql
   # service mysqld s to p
2.屏蔽权限
   # mysqld_safe --skip-grant-table
   屏幕出现: Starting demo from .....
3.新开起一个终端输入
   # mysql -u root mysql
   mysql> UPDATE  user  SET Password=PASSWORD('newpassword') where  USER ='root';
   mysql> FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
   mysql> \q

方法二:
1.关闭mysql
   # service mysqld s to p
2.屏蔽权限
   # mysqld_safe --skip-grant-table
   屏幕出现: Starting demo from .....
3.新开起一个终端输入
   # mysql -u root mysql
   mysql> delete from  user  where  USER ='';
   mysql> FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
   mysql> \q

本文转载自:http://cx7863.blog.163.com/blog/#m=0&t=3&c=mysql
不过本人mysql数据库远程连接开启方法用的是:
允许任何主机使用“myuser”账号和“mypwd”密码连接到 MySQL 服务器。
mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypwd' WITH GRANT OPTION; 
mysql> FLUSH PRIVILEGES;
允许用户myuserip192.168.1.3的主机连接到mysql服务器,并使用mypwd作为密码
mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypwd' WITH GRANT OPTION; 
mysql> FLUSH PRIVILEGES;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值