Chinaunix首页 | 论坛 | 博客
  • 博客访问: 236154
  • 博文数量: 22
  • 博客积分: 512
  • 博客等级: 下士
  • 技术积分: 242
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-17 09:48
文章分类

全部博文(22)

文章存档

2013年(1)

2012年(21)

我的朋友

分类: Mysql/postgreSQL

2012-02-17 09:51:31

一.一般安装完LINUX后,MYSQL没有经过配置就用如下命令启动MYSQL会出错的.
# service mysqld start
初始化 MySQL 数据库: Neither host 'localhost.localdomain' 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
[失败]
解决办法:
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后,保存退出。
二.启动mysql:
(1)#service mysql start
(2)#/etc/init.d/mysqld start
启动 MySQL:                                               [确定]
三.停止MySQL可以用如下命令:
(1)#service mysql stop
(2)#/etc/init.d/mysqld stop
停止 MySQL:                                               [确定]
(3)#mysqladmin shutdown
mysqld 已死,但是 subsys 被锁
四.检验MySQL是否被启动
#service mysqld status
mysqld (pid 5659) 正在运行...
五.连接进入MySQL数据库
#mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.22
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
这是第一次进入MySQL数据库,只有是root才能进入,默认密码为空。
要退出数据库只需键入'\q'就行了。
mysql>\q
Bye
#
六.设置MySQL管理员的密码
# mysqladmin -u root password 密码字符窜
设置好后再用mysql进行连接将会出错。
# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
应用如下命令:
# mysql -u root -p
Enter password:
在输入正确密码后将输出如下结果并进入数据库。
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.22
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
七.修改MySQL管理员的密码
[root@localhost ~]# mysqladmin -u root -p password 新密码字符窜
Enter password:
此时系统会提示你要输入旧密码,只有输入的密码正确才会修改成功。否则将会出错:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
以上操作都是在CentOS LINUX5.0 下实现的,在其它版本的LINUX配置MYSQL的命令也一样。

阅读(9521) | 评论(1) | 转发(1) |
0

上一篇:没有了

下一篇:Linux 安装 Mysql

给主人留下些什么吧!~~

马夹GG2012-02-20 21:49:13

初始化为什么会失败呢?