mysql -u 报错_MySQL报错解决!

大家好:我是小狼,最近工作一直瞎忙,没时间写东西,终于有点时间了,现在我正在搭建extmail服务器,文档是参考这里:http://www.extmail.org/forum/thread-7002-1-1.html

做到安装 ExtMail 1.0.3 和 ExtMan 0.2.3需要导入 ExtMail 和 ExtMan 所需要的数据库时,输入下面命令会报错:mysql -u root -p < /usr/local/apache2/htdocs/extsuite/extman/docs/extmail.sql

报错信息为:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

我在网上查了半天终于在一个人的文档里面找到解决方法了,他帖子地址是:http://www.jb51.net/LINUXjishu/10981.html

方法如下:

# /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/mysql restart

# mysql -uroot -p

Enter password:

mysql>

下面是我的操作:

# /etc/init.d/mysql stop

mysql -u root -p

Enter password: (此处用空密码登陆,要多尝试几次才成功的,不知原因)

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.0.45-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use mysql;

Database changed

mysql> UPDATE user SET Password=PASSWORD('redhat') where USER='root';

Query OK, 2 rows affected (0.00 sec)

Rows matched: 2  Changed: 2  Warnings: 0

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

mysql> quit

Bye

[root@localhost ~]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.0.45-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> quit

Bye

按照此方法做成功了,mysql -u root -p 之后会让你输入密码,输入刚才设置的密码进入数据库就OK了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值