首页 文章

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

提问于
浏览
0

我成功地在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)'以及其他许多我失去了轨道的东西 - 太多而且没有一个起作用 .

Update

请看下面的内容:

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

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

    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

  • 0

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

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

    即使你可以尝试没有密码,如下所示,并从mysql提示设置root密码 -

    mysql -uroot
    
  • 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的条目,但文件现在已经消失了 . 无论哪种方式,这都是解决方案!

相关问题