手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux中mysqly一些问题的解决

[日期:2007-08-22] 来源:Linux公社  作者:Linuxidc [字体:大 中 小]
刚刚装好linux as 4.
现在面临的第一个问题就是怎么用上自带MySQL>[root@server tmp] rmp -qa|grep mysql 察看当前mysql版本.

一:
当我在命令行输入mysql时出现了:Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.soc的错误的话.
解决的办法是:由于mysql 服务还没有启动。试试看:>>>service mysqld starty

二:
root@localhost www]# service mysqld start
Initializing MySQL database: Neither host 'localhost' nor 'localhost' could be looked up with
/usr/bin/resolveip
Please configure the 'hostname' command to return a correct hostname.
If you want to solve this at a later stage, restart this script with
the --force option
[FAILED]
[root@localhost www]#
处 理:
1、$ ping localhost
ping: unknown host localhost
ping也不成功,确定可能为localhost解析原因。
2、查看/etc/hosts,内容如下:
# Do not remove the following line, or various programs
# that require network functionality will fail.
::1 localhost.localdomain localhost
3、将::1修改为127.0.0.1后,启动成功。

三:mysqladmin -u root -p password
想输入空密码,但居然说
mysqladmin:connect to server at'localhost' failed
erroe:'acces denied for user 'root@127.0.0.1'
试试这个:>mysql -u root -p 123456
Enter password:123456

或者参考:
使用网上介绍的方法修改root用户的密码:
# mysqladmin -uroot -p password 'newpassword'
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

现在终于被我找到了解决方法,如下(请先测试方法三,谢谢!):
方法一:
# /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: <输入新设的密码newpassword>linux
相关资讯       mysql 
本文评论   查看全部评论 (1)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款
第 1 楼
* nlwz 发表于 2011/10/11 14:50:59
我有同样的困惑,不过最终解决了,原来是自己的数据库主机名设置错误了,主机名godaddy上有的看的。去看看是不是错了。。。