MySQL 1045 无法登录MySQL服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17914571/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
1045 cannot log in to the MySQL server
提问by Happy
After I downloaded:
我下载后:
- Wampserver 2.4
- Apache version 2.4.4
- PHP version 5.4.12
- MySQL version 5.6.12
- Wampserver 2.4
- Apache 版本 2.4.4
- PHP 版本 5.4.12
- MySQL 版本 5.6.12
On Wampserver 2.4, make put online -> start all -> click localhost -> click phpMyAdmin.
在 Wampserver 2.4 上,使联机 -> 全部启动 -> 单击 localhost -> 单击 phpMyAdmin。
On phpMyAdmin screen:
在 phpMyAdmin 屏幕上:
Welcome to phpMyAdmin
Language - English
Log in
Username
Password
欢迎使用 phpMyAdmin
英语语言
登录
用户名
密码
phpMyAdmin requires username and password.
phpMyAdmin 需要用户名和密码。
I did not make any username and password for phpMyAadmin.
我没有为 phpMyAadmin 设置任何用户名和密码。
I had no idea, but if I insert some user name and password, it says:
我不知道,但是如果我插入一些用户名和密码,它会说:
1045 cannot log in to the MySQL server
1045 无法登录MySQL服务器
Please let me know what I did wrong.
请让我知道我做错了什么。
For your reference,
wamp\apps\phpmyadmin4.0.4\config.in.php
code:
供您参考,
wamp\apps\phpmyadmin4.0.4\config.in.php
代码:
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* phpMyAdmin sample configuration, you can use it as base for
* manual configuration. For easier setup you can use setup/
*
* All directives are explained in documentation in the doc/ folder
* or at <http://docs.phpmyadmin.net/>.
*
* @package PhpMyAdmin
*/
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = 'a8b7c6d'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/*
* Servers configuration
*/
$i = 0;
/*
* First server
*/
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
/*
* phpMyAdmin configuration storage settings.
*/
/* User used to manipulate with storage */
// $cfg['Servers'][$i]['controlhost'] = '';
// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = 'pmapass';
/* Storage database and tables */
// $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]['table_uiprefs'] = 'pma__table_uiprefs';
// $cfg['Servers'][$i]['tracking'] = 'pma__tracking';
// $cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
// $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
// $cfg['Servers'][$i]['recent'] = 'pma__recent';
/* Contrib / Swekey authentication */
// $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';
/*
* End of servers configuration
*/
/*
* Directories for saving/loading files from server
*/
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
/**
* Defines whether a user should be displayed a "show all (records)"
* button in browse mode or not.
* default = false
*/
//$cfg['ShowAll'] = true;
/**
* Number of rows displayed when browsing a result set. If the result
* set contains more rows, "Previous" and "Next".
* default = 30
*/
//$cfg['MaxRows'] = 50;
/**
* disallow editing of binary fields
* valid values are:
* false allow editing
* 'blob' allow editing except for BLOB fields
* 'noblob' disallow editing except for BLOB fields
* 'all' disallow editing
* default = blob
*/
//$cfg['ProtectBinary'] = 'false';
/**
* Default language to use, if not browser-defined or user-defined
* (you find all languages in the locale folder)
* uncomment the desired line:
* default = 'en'
*/
//$cfg['DefaultLang'] = 'en';
//$cfg['DefaultLang'] = 'de';
/**
* default display direction (horizontal|vertical|horizontalflipped)
*/
//$cfg['DefaultDisplay'] = 'vertical';
/**
* How many columns should be used for table display of a database?
* (a value larger than 1 results in some information being hidden)
* default = 1
*/
//$cfg['PropertiesNumColumns'] = 2;
/**
* Set to true if you want DB-based query history.If false, this utilizes
* JS-routines to display query history (lost by window close)
*
* This requires configuration storage enabled, see above.
* default = false
*/
//$cfg['QueryHistoryDB'] = true;
/**
* When using DB-based query history, how many entries should be kept?
*
* default = 25
*/
//$cfg['QueryHistoryMax'] = 100;
/*
* You can find more configuration options in the documentation
* in the doc/ folder or at <http://docs.phpmyadmin.net/>.
*/
?>
回答by Joren
Log in using the default password:
使用默认密码登录:
Username: root
Password: [null]
用户名:root
密码:[空]
With [null] I mean no password at all.
[null] 我的意思是根本没有密码。
回答by lasa108
After installation, on Start Menu, Try right click on "start WampServer" and "Run as Administrator". Then can login to MySQL (PHPMyAdmin) as root without any password .
安装后,在开始菜单上,尝试右键单击“启动 WampServer”和“以管理员身份运行”。然后可以无需任何密码以root身份登录MySQL(PHPMyAdmin)。
(In my case, the installation on a windows 7 machine was done by a user with admin role. But when I tried to click on "start WampServer" it would only go upto orange. After searching a few blogs which pointed at changing certain config file, the above occurred to me, and it worked).
(就我而言,Windows 7 机器上的安装是由具有管理员角色的用户完成的。但是当我尝试单击“启动 WampServer”时,它只会变为橙色。在搜索了一些指向更改某些配置的博客后文件,上述情况发生在我身上,并且有效)。
回答by Bosun Agunbiade
1) Open your MySQL console - using wamp , left click your WAMP icon located at the bottom right of your desktop and click on MySQL Console You will be prompted to enter a password , if you have one you can ignore the following steps
1) 打开您的 MySQL 控制台 - 使用 wamp ,左键单击位于桌面右下角的 WAMP 图标,然后单击 MySQL 控制台您将被提示输入密码,如果您有密码,则可以忽略以下步骤
Press ENTER Type in: use mysql
按 ENTER 输入:使用 mysql
Press ENTER
按 ENTER
2) Enter the following on the command line
2)在命令行输入以下内容
To set your MySQL Password: UPDATE mysql.user SET Password=PASSWORD("EnterYourPasswordHere") WHERE User="root"; Replace "EnterYourPasswordHere" with your new chosen password.
设置你的 MySQL 密码: UPDATE mysql.user SET Password=PASSWORD("EnterYourPasswordHere") WHERE User="root"; 用您选择的新密码替换“EnterYourPasswordHere”。
Press ENTER.
按 ENTER。
Flush the privileges: Type FLUSH PRIVILEGES;
刷新权限:输入 FLUSH PRIVILEGES;
Exit by typing : Exit
通过键入退出:退出
then ENTER
然后输入
3) Open and Edit your config.inc.php file located in your local sever files
3) 打开并编辑位于本地服务器文件中的 config.inc.php 文件
Go to My Computer > C Drive > (Your Local Server Folder, WAMP/MAMP/XAMPP) > APPS > PHPMYADMIN > config.inc.php Find this line of code: $cfg['Servers'][$i]['password'] = ''; // MySQL password
进入我的电脑>C盘>(你的本地服务器文件夹,WAMP/MAMP/XAMPP)>APPS>PHPMYADMIN>config.inc.php找到这行代码:$cfg['Servers'][$i]['password '] = ''; // MySQL 密码
Change 'password' to the new chosen password you created from Step 2.
将“密码”更改为您在步骤 2 中创建的新选择的密码。
Click Save.
单击保存。
4) You can access phpMyAdmin by going to http://localhost/phpMyAdmin/.
4) 您可以通过访问http://localhost/phpMyAdmin/来访问 phpMyAdmin 。
Congratulations! You are now able to access your databases.
恭喜!您现在可以访问您的数据库。