1.检查是否密码错误,是否有多余空格
2.没有授权
GRANT ALL PRIVILEGES ON *.* TO root @'%' IDENTIFIED BY "mypassword";-- % 表示所有的IP都能访问,也可以修改为专属的
-- mypassword 为连接密码 需要修改为你自己的
FLUSH PRIVILEGES;
-- password,在高级版本中被字段 ,authentication_string 所替换;
3.权限不足
修改/etc/my.cnf ,Windows下是my.ini文件,在[mysqld] 下添加一行 skip-grant-tables;
重启mysql:service mysqld restart
登录mysql:mysql -h localhost -u root mysql;
修改密码:update user set password=PASSWORD("*****") where user='root';
新版本(5.5)之后:update mysql.user set authentication_string=password('*****') where user='root';
修改my.cnf ,删除 skip-grant-tables;
重启mysql:service mysqld restart
即可访问
或者:
grant all privileges on *.* to root@'%' identified by '密码';
flush privileges;