Linux中mysql问题种种

刚刚装好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' <using password:'no>
试试这个:>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>