Chinaunix首页 | 论坛 | 博客
  • 博客访问: 23057
  • 博文数量: 5
  • 博客积分: 147
  • 博客等级: 入伍新兵
  • 技术积分: 75
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-15 12:37
文章分类

全部博文(5)

文章存档

2012年(5)

我的朋友

分类: Mysql/postgreSQL

2012-08-30 23:30:08

、在命令模式下直接敲mysql可以进入mysql:
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.1.49-community-log MySQL Community Server (GPL)
。。。


2、创建数据库出错:
mysql> create database tmonitor;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'tmonitor'
mysql>

我明明是root登录的,为什么会是''@'localhost' ?

3、另外,我show一下数据库,却发现没有'mysql'库,咋回事?我记得mysql数据库中默认有个名叫‘mysql’的数据库,用来维护用户名、配置参数等信息的库啊:

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.00 sec)

mysql>

4、如果是因为匿名登录,那我退出重新进入mysql吧:

mysql> exit
Bye
[root@localhost ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost ~]#

——访问被拒绝了。。。。。。

各位大牛,这是咋回事?
是不是因为没有‘mysql’数据库,导致根本不存在‘root’这个用户,从而导致认证失败的?


回来结贴了,问题解决了,详述如下:
思路还是重置密码,方法也是如下所述:

/etc/init.d/mysql stop (service mysqld stop )
/usr/bin/mysqld_safe --skip-grant-tables
另外开个SSH连接
[root@localhost ~]# mysql
mysql>use mysql
mysql>update user set password=password("123456") where user="root";
mysql>flush privileges;
mysql>exit

pkill -KILL -t pts/0 可将pts为0的**用户(之前运行mysqld_safe的用户窗口)强制踢出
正常启动 MySQL:/etc/init.d/mysql start (service mysqld start)

问题出在最后一步:你pkill时,pts/X,其中的‘X’不一定是0,可能是1,也可能是2,也可能是。。。所以你kill pts/0 肯定就不对了。你可以用'ps aux | grep pts'查到你重置密码的SSH窗口。
其实吧,上面那是文明的粗鲁做法,最简单的是粗鲁的文明做法:直接把重置密码的SSH窗口关闭就行了,哈哈
阅读(1873) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~