问题:
1.遇到不输入密码能登上 ,使用密码报错.2.(解压版的) 在cmd输入>mysql –u root –p 时,按enter回车时,会叫你输入密码Enter password____,否则出现错误:ERROR 1045(28000):Access denied for user’root’@’localhost’(using password:YES) 或者是 (using password:NO)解决操作:
1.我们的先找到安装目录下的 my.ini文件. 2.编辑my.ini文件,在里面的[mysqld]条目下加上 skip-grant-tables,保存 .3.以管理员权限运行cmd,停止mysql服务(安装版 的默认名mysql57 版本不一样有的是mysql56),输入:net stop mysql 再启动,输入net start mysql(没配置好path的要找到bin目录下才输入) 4.输入:mysql –u root –p回车 .5.进入到Enter password___ //这时可以直接按 enter键回车跳过.6.此时我们进入了mysql数据库(但权限很低) 执行:Mysql>use mysql; 7.给root用户设置新密码 (下面的一句和网上的一些方法不一样,注意.) 执行:Mysql>update user set password=password('这里是你要的密码,自己输入用英文输入法的单引号括住')where user='root';8.刷新数据库 Mysql>flush privileges; 9.退出mysql Mysql>quit; 10.这时重启服务就可以了(当然,别忘了先删除my.ini里面的skip-grant-tables)11.上面修改后登陆后有问题看下面.实例:红色字体是要用到的语句,蓝色字体自己输入.mysql> use mysql;Database changedmysql> UPDATE user SET Password=PASSWORD('root') where USER='root';ERROR 1054 (42S22): Unknown column 'Password' in 'field list'mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host='localhost';Query OK, 1 row affected, 1 warning (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privilages;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to yourMySQL server version for the right syntax to use near 'privilages' at line 1mysql> flush privileges;Query OK, 0 rows affected (0.01 sec)mysql> quit;
ByeD:\Mysql\mysql-5.7.16-winx64\bin>mysql -uroot -p123qwe; (这个时候这样输入会报错)
mysql: [Warning] Using a password on the command line interface can be insecure.ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)D:\Mysql\mysql-5.7.16-winx64\bin>mysql -uroot -p
Enter password: ******Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.16Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
登陆后如果不能执行任何语句 报错:You must reset your password using ALTER USER statement before executing this statement.安装完mysql 之后,登陆以后,不管运行任何命令,总是提示上面错误语句,就在登录后,
以此执行下面语句(红色字体自己输入最好,因为标点格式可能不对)1: SET PASSWORD = PASSWORD('your new password');
2: ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
3: flush privileges;
完成以上三步退出再登,使用新设置的密码(就是括号里的your new password)就行了.