免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1388 | 回复: 0
打印 上一主题 下一主题

[转贴]ubuntu上数据库刚安装访问问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-04-02 13:45 |只看该作者 |倒序浏览
原帖地址:http://www.91linux.com/html/article/database/mysql/20081129/14084.html
  用如下命令在ubuntu上安装了mysql之后
  sudo apt-get install mysql-server
  sudo apt-get install mysql-client
  sudo /etc/init.d/mysql start 如果
rpm安装完毕后,直接用
/usr/bin/mysqladmin -u root password “newpasswd”修改密码后出现

错误信息。
解释:YES,说明密码没有问题。可能是限制不让在本地登陆。于是实用
添加 -h 61.139.xx.252绕过本地测试,也未成功
   
        
            [root@fms1 ok]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user
[email=%27root%27@%27localhost%27]'root'@'localhost'[/email]
(using password: YES)
[root@fms1 ok]# mysql -h 61.139.xx.252 -u root -p
Enter password:
ERROR 1130 (00000): Host '61.139.76.252' is not allowed to connect to this MySQL server
        
   
注释: 1130报错信息说明不允许远程访问。没有给该用户授权
然后重新修改密码后可以正常访问:
   
        
            
            [root@fms1 ok]# [color="#ff0000"]/etc/init.d/mysql stop
Shutting down MySQL.[确定]
[root@fms1 ok]# [color="#ff0000"]mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 6699
[root@fms1 ok]# [color="#ff0000"]mysql -u root mysql
            [color="#ff0000"].......
mysql> [color="#ff0000"]show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)
            mysql> [color="#ff0000"]use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
            Database changed
            mysql> [color="#ff0000"]show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
.............................
            .............................
            .............................
| user                      |
+---------------------------+
17 rows in set (0.00 sec)
            mysql> [color="#ff0000"]UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0
            mysql> [color="#ff0000"]FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
            mysql> [color="#ff0000"]quit
Bye
            注:到此修改密码完成。
            [root@fms1 ok]# [color="#ff0000"]killall -9 mysqld
[root@fms1 ok]# /etc/init.d/mysql start
Starting MySQL[确定]
[root@fms1 ok]# [color="#ff0000"]mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.45-community MySQL Community Edition (GPL)
            Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
            mysql> [color="#ff0000"]GRANT ALL PRIVILEGES ON *.* TO
[email=root@%27%%27][color="#ff0000"]root@'%'[/email]
[color="#ff0000"] IDENTIFIED BY "newpasswd";  #用于给用户授权。
Query OK, 0 rows affected (0.00 sec)
            mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
            mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
            Database changed
mysql> [color="#ff0000"]update user set user="newname" where user="root"; #改名。
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0
            mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
            mysql> quit
Bye
            [color="#0000ff"]支持完成了修改密码,授权,改名的工作。
[root@fms1 ok]# mysql -u centos -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.45-community MySQL Community Edition (GPL)
            Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
            mysql> show databases;
            
        
   
错误信息没有了。

总结:
错误提示:
# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
解决方法:1
方法一:
# /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:
完成。
   
        
             ERROR 1045 (28000): Access denied for user
[email=%27root%27@%27localhost%27]'root'@'localhost'[/email]
(using password: [color="#ff0000"]YES)
        
   

               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/88420/showart_1888547.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP