MySQL - 无法登录 - 拒绝访问 - 全新安装(OpenWRT)

时间:2016-01-04 11:14:57

标签: mysql openwrt

我成功地在OpenWRT上安装了MySql而没有任何错误 - 请参阅下文,但我遇到登录问题 - 它告诉我拒绝访问。但根据我在互联网上找到的所有内容,默认用户名是root,没有密码所以我必须是一个特例。

请看下面的内容:

root@OpenWrt:~# mysql_install_db

    Installing MySQL system tables...
    OK
    Filling help tables...
    OK

    To start mysqld at boot time you have to copy
    support-files/mysql.server to the right place for your system

    PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
    To do so, start the server, then issue the following commands:

    /usr/bin/mysqladmin -u root password 'new-password'
    /usr/bin/mysqladmin -u root -h OpenWrt password 'new-password'

    Alternatively you can run:
    /usr/bin/mysql_secure_installation

    which will also give you the option of removing the test
    databases and anonymous user created by default.  This is
    strongly recommended for production servers.

    See the manual for more instructions.

    You can start the MySQL daemon with:
    cd /usr ; /usr/bin/mysqld_safe &

    You can test the MySQL daemon with mysql-test-run.pl
    cd /usr/mysql-test ; perl mysql-test-run.pl

    Please report any problems with the /usr/scripts/mysqlbug script!

root@OpenWrt:~#  

然后我启动服务器:

root@OpenWrt:~# /usr/bin/mysqld &
root@OpenWrt:~# 160104 10:48:04 [Note] Event Scheduler: Loaded 0 events
160104 10:48:04 [Note] /usr/bin/mysqld: ready for connections.
Version: '5.1.73'  socket: '/var/run/mysqld.sock'  port: 5158  Source distribution

然后我尝试登录:

root@OpenWrt:~# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
root@OpenWrt:~#

然后我尝试了:

root@OpenWrt:~# mysqladmin -u root -p root
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
root@OpenWrt:~#

在上面,我输入了密码:" root"什么时候它问我。 我也试过把它留空但没有运气。我也试过了(' new-password')。

我花了几个小时搜索这个网站和其他网站,但没有一个我尝试过的建议。另外,在我的情况下,mysqld_safe似乎没有安装(我不相信它可用于OpenWRT)。

参考点:http://forums.mysql.com/read.php?34,140320,140324http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.htmlHow to find out the MySQL root password'Access denied for user 'root'@'localhost' (using password: NO)'以及其他许多我失去追踪的内容 - 太多而且没有一个可以使用。

更新

请看下面的内容:

root@OpenWrt:~# /usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

root@OpenWrt:~# /usr/bin/mysqladmin -u root password 'root'
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

root@OpenWrt:~# /usr/bin/mysqladmin -u root password 'admin'
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

root@OpenWrt:~# mysqladmin reload
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

root@OpenWrt:~# /usr/bin/mysqladmin -u root password
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

3 个答案:

答案 0 :(得分:0)

您是否尝试过按照安装后的说明进行操作?具体是:

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'

可能是没有创建root用户或者有这样的用户。

也可能强制重新加载数据库,尤其是在添加用户以强制重新加载用户表时:

mysqladmin reload

HTH

答案 1 :(得分:0)

正如mysql日志文件所示,请尝试以下comamnd -

1. Find the kth Grey Code  k^(k>>1)
2. Find the neighboring corners of a corner in a cube:
rep (i, number_of_corners) {
            rep (j, N) {
                corners[i].sum += corners[(i ^ (1 << j))].weight;
            }
        }

即使您可以尝试不使用密码,也可以在mysql提示符下设置root密码 -

/usr/bin/mysqladmin -u root password 'your_root_password';

答案 2 :(得分:0)

我修好了!我发现问题是什么!

MySql在其表中查找用户名,如果它一直告诉我“拒绝访问”,则表示“root”用户很可能不存在(因为它是全新的安装)。所以我删除了整个安装并删除了“一切”MySql关联。

我使用--help选项运行安装脚本并检查出来!

  --user=user_name     The login username to use for running mysqld.  Files
                       and directories created by mysqld will be owned by this
                       user.  You must be root to use this option.  By default
                       mysqld runs using your current login name and files and
                       directories that it creates will be owned by you.

然后,我再次运行脚本,但是我传递了--user = root参数:

mysql_install_db --user = root

root@OpenWrt:~# mysql_install_db --user=root

瞧! :)

root@OpenWrt:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

说完这个,现在我想,我可能用记事本或某种数据库编辑器搜索数据库,因为它们是ASCII格式,看看我是否可以找到root用户的条目,但文件已经消失了现在。无论哪种方式,这都是解决方案!