mysql 报错ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executin
mysql> help contents
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> help contents
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
解决办法
1、 修改用户密码
mysql> alter user 'root'@'localhost' identified by 'youpassword';
或者
mysql> set password=password("youpassword");
2、刷新权限
mysql> flush privileges;
mysql> help contents
You asked for help about help category: "Contents"
For more information, type 'help <item>', where <item> is one of the following
categories:
Account Management
Administration
Compound Statements
Data Definition
Data Manipulation
Data Types
Functions
Functions and Modifiers for Use with GROUP BY
Geographic Features
Help Metadata
Language Structure
Plugins
Procedures
Storage Engines
Table Maintenance
Transactions
User-Defined Functions
Utility
mysql>
远程连接MYSQL数据库,报1130错误的解决方法
重装MySQL,由于不知道重装之前的root密码,使用重装之后的密码连接Mysql数据,总报 ERROR 1130: host 'localhost' not allowed to connect to this MySQLserver,不能连接数据库,猜测用户权限和密码的问题。
1、用root用户登录mysql数据库
(1)停止MySQL服务,执行net stop mysql;
(2)在mysql的安装路径下找到配置文件my.ini,
找到[mysqld]
输入:skip-grant-tables,保存
(3)重启mysql服务,net start mysql;
(4)执行mysql -uroot -p,回车,再回车,即可进入mysql数据库;
2、在本机登入mysql后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改称'%'。
mysql>use mysql;
mysql>select host,user,password from user;
mysql>update user set host = '%' where user ='root';
mysql>flush privileges; #刷新用户权限表
mysql>select host,user,password from user where user='root';
3、插入本地登录的用户
mysql>insert into user values('localhost', 'root', '', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y','','','','',0,0,0,0,'','');
此时本地连接的用户localhost密码为空
4、修改root密码
(1)用set password 方式修改root密码遇到错误ERROR 1290 (HY000)
mysql> set password for root@'localhost'=PASSWORD('12345');
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot exe
cute this statement
注意:以skip-grant-tables方式启动mysql后,不能用直接用set password的方式修改root密码,须注释skip-grant-tables, 然后重启服务,连接数据库修改密码
(2)用update方式修改root密码正常
mysql> update user set password=password("123") where user="root";
mysql>flush privileges;
(3)不连接数据库,直接在cmd下修改密码
mysqladmin -uroot -p旧密码 password 新密码,此种方式修改密码也不能在以“skip-grant-tables“方式启动mysql后进行
如:mysqladmin -uroot -p123456 password 1234
5、退出MySQL,在配置文件中注释:skip-grant-tables,重启mysql服务
6、本地重新连接mysql数据库,输入修改后的密码,连接成功