#1045 - 用户'root'@'localhost'的访问被拒绝(使用密码:NO):甚至来自命令行

时间:2016-01-04 09:21:44

标签: php mysql mysqli xampp localhost

我搜索了解决方案,但我根本找不到它!

两年前我安装了Xampp,直到昨天它都运行良好。 我曾经在“http://localhost:8080/phpmyadmin/”管理MySql,但现在它向我显示了这个错误:

#1045 - Access denied for user 'root'@'localhost' (using password: NO) 

如果我尝试从命令行,shell或ssh管理mysql用户,我总是得到同样的错误! 这是我的config.inc.php

$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Lang'] = '';

/* Bind to the localhost ipv4 address and tcp */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'tcp';

/* User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '';

/* Advanced phpMyAdmin features */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
$cfg['Servers'][$i]['relation'] = 'pma_relation';
$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
$cfg['Servers'][$i]['history'] = 'pma_history';
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
$cfg['Servers'][$i]['tracking'] = 'pma_tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';
$cfg['Servers'][$i]['recent'] = 'pma_recent';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma_table_uiprefs';
$cfg['Servers'][$i]['users'] = 'pma_users'; 
$cfg['Servers'][$i]['usergroups'] = 'pma_usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma_navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma_savedsearches';

...这是my.ini

# The following options will be passed to all MySQL clients
[client] 
# password       = your_password 
port            = 3306 
socket          = "C:/xampp/mysql/mysql.sock"


# Here follows entries for some specific programs 

# The MySQL server
[mysqld]
port= 3306
socket = "C:/xampp/mysql/mysql.sock"
basedir = "C:/xampp/mysql" 
tmpdir = "C:/xampp/tmp" 
datadir = "C:/xampp/mysql/data"
pid_file = "mysql.pid"
# enable-named-pipe
key_buffer = 16M
max_allowed_packet = 1M
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log_error = "mysql_error.log"

每一个帮助都会受到赞赏......

2 个答案:

答案 0 :(得分:1)

1045 - 拒绝用户访问权限&root;' @' localhost' (使用密码:否)

  1. 打开位于C:\ wamp \ bin \ mysql \ mysql [version] \ my.ini

  2. 的my.ini文件
  3. 更改密码字段

  4. from this->

    #password = your_password port = 3306 socket = /tmp/mysql.sock

    to this->

    password = password port = 3306 socket = /tmp/mysql.sock

    1. 现在转到C:\wamp\apps\phpmyadmin[version]config.inc.php并更改
    2. 这一行 - > $cfg['Servers'][$i]['auth_type'] = 'config';

      到此 - > $cfg['Servers'][$i]['auth_type'] = 'cookie';

      这一行 - > $cfg['Servers'][$i]['user'] = 'root';

                $cfg['Servers'][$i]['password'] = '';`
      

      到此 - > $cfg['Servers'][$i]['user'] = 'root';

                $cfg['Servers'][$i]['password'] = 'password';`
      
      1. 重启wamp服务器的所有服务

      2. 现在在浏览器的wamp start页面中键入localhost

      3. 点击phpmyadmin,它将打开MySQL的登录页面,使用您的

      4. 登录

        username = user

        密码= password

        1. 这应该可以解决您的问题

答案 1 :(得分:0)

我丢失了“root”密码,因此我没有管理员权限。我在this

之后解决了这个问题

指导,更新密码。重新启动电脑后,它有效... 希望这可以帮助...