求助 mysql登录不了

回复 收藏
本帖最后由 tufei123 于 2016-5-13 16:46 编辑

[root@tufei init.d]# /usr/local/mysql/bin/mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
就得到这样的提示  http://www.test.com/static/image/common/logo.png
2016-05-08 20:11 举报
已邀请:
0

杨金彪

赞同来自:

+1
0

tufei123

赞同来自:

{:5_133:} 百度的答案好像都没有用
0

栋佐

赞同来自:

你应该是自己设置了密码吧。/usr/local/mysql/bin/mysql -uroot -p  然后输入密码登录。
0

乐橙306

赞同来自:

1045:不能连接数据库,用户名或密码错误

http://www.apelearn.com/bbs/thread-10561-1-1.html
0

tufei123

赞同来自:

栋佐 发表于 2016-5-8 21:06
你应该是自己设置了密码吧。/usr/local/mysql/bin/mysql -uroot -p  然后输入密码登录。

我都没有设置密码 怎么取消阿
0

tufei123

赞同来自:

{:7_194:}人人人人人
0

追梦人

赞同来自:

是不是没有做授权啊,你看看日志文件排查一下吧!
0

tufei123

赞同来自:

# vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables

mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0  Changed: 0  Warnings: 0

改不了密码
0

沧海一叶

赞同来自:

1.配置文件加上 skip-grant-tables   然后直接登录试试
0

沧海一叶

赞同来自:

2.不使用任何参数直接mysql登录试试
0

tufei123

赞同来自:

沧海一叶 发表于 2016-5-9 08:28
2.不使用任何参数直接mysql登录试试


[root@tufei ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
0

tufei123

赞同来自:

沧海一叶 发表于 2016-5-9 08:27
1.配置文件加上 skip-grant-tables   然后直接登录试试

mysql> grant all on discuz.* to 'tufei'@'localhost' identified by 'tufeilinux';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
服务器运行带有--跳过授权表选项所以它不能执行此语句
做到这步就不行了
0

malong

赞同来自:

/usr/local/bin/mysql -uroot -p 试试
0

tufei123

赞同来自:

malong 发表于 2016-5-9 10:25
/usr/local/bin/mysql -uroot -p 试试


[root@tufei ~]# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@tufei ~]# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
没设置密码
0

沧海一叶

赞同来自:

tufei123 发表于 2016-5-9 09:40
mysql> grant all on discuz.* to 'tufei'@'localhost' identified by 'tufeilinux';
ERROR 1290 (HY000 ...

你能进MYSQL命令行你就改掉ROOT的密码就可以了,你这样在授权用户 配置文件中都定义了跳过权限检查。
0

malong

赞同来自:

这个肯定是你之前安装过mysql 设置过密码,用之前的密码试试
0

malong

赞同来自:

或者是你没把之前的删除干净造成的,用你上个MySQL数据库密码试试
0

tufei123

赞同来自:

沧海一叶 发表于 2016-5-9 10:48
你能进MYSQL命令行你就改掉ROOT的密码就可以了,你这样在授权用户 配置文件中都定义了跳过权限检查。

怎么改啊 好像改不了
0

tufei123

赞同来自:

malong 发表于 2016-5-9 10:50
或者是你没把之前的删除干净造成的,用你上个MySQL数据库密码试试

我把它卸载看看
0

乐橙306

赞同来自:

mysql  忘记root密码

参考文档
http://www.apelearn.com/bbs/fo ... 3D252

如果忘记root密码或其他用户密码,不要急,按下面操作即可。
1. 编辑mysql主配置文件 my.cnf
vim /etc/my.cnf  
在[mysqld]字段下添加参数  
skip-grant  
2. 重启数据库服务
service mysqld restart
3. 这样就可以进入数据库不用授权了
mysql -uroot
4. 修改相应用户密码
use mysql;
update user set password=password('1234567890) where user='root';
flush privileges;
5.  修改/etc/my.cnf 去掉 skip-grant , 重启mysql服务
6.  mysql  -uroot  -p
0

tufei123

赞同来自:

乐橙306 发表于 2016-5-9 11:18
mysql  忘记root密码

参考文档


mysql> update user set password=password('1234567890') where user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0  Changed: 0  Warnings: 0
这个是修改成功了?
0

乐橙306

赞同来自:

tufei123 发表于 2016-5-9 11:24
mysql> update user set password=password('1234567890') where user='root';
Query OK, 0 rows affe ...

是的    按照步骤 继续操作
0

tufei123

赞同来自:

本帖最后由 tufei123 于 2016-5-9 11:42 编辑
乐橙306 发表于 2016-5-9 11:32
是的    按照步骤 继续操作是密码不对吗
0

tufei123

赞同来自:

是密码不对吗
0

乐橙306

赞同来自:


cat  /etc/my.cnf   截图
0

malong

赞同来自:

编译安装的吧 MySQL要删除干净,要不然重装之后,还是需要密码
0

tufei123

赞同来自:

本帖最后由 tufei123 于 2016-5-9 11:59 编辑
乐橙306 发表于 2016-5-9 11:46
cat  /etc/my.cnf   截图

0

乐橙306

赞同来自:


find  / -name  mysql   截图
0

tufei123

赞同来自:

本帖最后由 tufei123 于 2016-5-9 12:17 编辑

find  / -name  mysql   截图
0

tufei123

赞同来自:

乐橙306 发表于 2016-5-9 12:07
find  / -name  mysql   截图

30楼图
0

tufei123

赞同来自:

malong 发表于 2016-5-9 11:51
编译安装的吧 MySQL要删除干净,要不然重装之后,还是需要密码

是编译安装的
0

Linux-lucky

赞同来自:

方法一:
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit

# /etc/init.d/mysqld restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>

mysql>

方法二:
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:
# mysql -udebian-sys-maint -p
Enter password: <输入[client]节的密码>
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit

# mysql -uroot -p
Enter password: <输入新设的密码newpassword>

mysql>

方法三:
这种方法我没有进行过测试,因为我的root用户默认密码已经被我修改过了,那位有空测试一下,把结果告诉我,谢谢!!
# mysql -uroot -p
Enter password: <输入/etc/mysql/debian.cnf文件中[client]节提供的密码>

修改密码的多种方法:
方法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;

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: