After installing a local server and trying to access phpMyAdmin, you could possibly encounter the error: #1045 Access Denied for user ‘root‘@‘localhost‘ (using password: YES).
If [email protected] wasn‘t granted the necessary rights to access the database or you provided the wrong password, you will then encounter this error.
Following this tutorial will help guide you on bypassing this error, for any local host server using phpMyAdmin.
If you get an Error #1045 in phpMyAdmin it will look like the image below:
Step 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.
- Guide to accessing MySQL using
XAMPP - Guide to accessing MySQL using MAMP.
Step 2: Enter the Provided Command Lines
If you have a password, you can ignore this part.
- Type in: use mysql;
- Press Enter.
- Set your MySQL Password: UPDATE mysql.user
SET Password=PASSWORD("EnterYourPasswordHere")
WHERE User="root";
- Replace "EnterYourPasswordHere" with your new chosen password.
- Press Enter.
- Flush the privileges: FLUSH PRIVILEGES;
- Exit by typing: Exit
- Press Enter.
Step 3: Open and edit your config.inc.php file located in your local server files
- Using a text editor, such as Notepad++, open your config.inc.php file.
- 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
- Change ‘password‘ to the new chosen password you created from Step 2.
- Click Save.
Step 4: Access phpMyAdmin
- You can access phpMyAdmin by going to http://localhost/phpMyAdmin/.
- Congratulations! You are now able to access your databases.
利用phpmyadmin修改mysql的root密码
时间:2010-08-09 整理:阅微草堂 点击:1384次 收藏本页 我要评论
很多人利用phpmyadmin或者命令行来修改了mysql的root密码,重启后发现mysql登录错误,这是为什么呢?修改mysql的root的密码要在mysql软件中mysql数据库里修改root的密码,还要在配置文件中修改。而且在数据库中的修改不止修改一行数据,所以千万不要手动修改,要用命令来修改。
本文帮助读者解决用phpmyadmin修改root密码问题和用phpmyadmin更改root密码后无法登陆问题
首先用root账号登陆phpmyadmin,然后点击左侧进入mysql数据库,在顶部点击“mysql”进入sql输入界面。输入以下命令:
update user set password=password(‘123456‘) where User=‘root‘
其中123456为你希望修改的密码,切记不要在数据库中直接手工修改密码。
修改mysql数据库root密码
然后点击右下角的“执行”,看到如下界面,就表示修改成功。(注意:有的mysql这里影响的列数并不是2)
phpmyadmin修改mysql数据库root密码成功
接着还要进入phpmyadmin目下下的libraries目录,修改config.default.php文件。找到$cfg[‘Servers‘][$i][‘password‘] = ‘ ‘,
修改为$cfg[‘Servers‘][$i][‘password‘] = ‘123456‘; 123456就是您想要的密码。重启mysql后新密码生效。
如果安装了wordpress,需要修改wordpress的配置文件(此处只需修改密码)
设置 wp-config.php
为了继续进行以下环节,请你找到以下代码并进行修改:
返回到你在第一步时解压WordPress包的地方,重命名wp-config-sample.php文件为wp-config.php. 用你喜欢的编辑器打开已经重命名的wp-config.php并且填写好以下信息,例如:
DB_NAME
你在第二步时为WordPress建立的数据库名称。
DB_USER
你在第二步建立WordPress数据库时创建的用户名。
DB_PASSWORD
你在第二步时为你数据库用户所创建的密码。
DB_HOST
你在第二步时决定的主机名(通常时localhost,但也不是绝对,请根据实际情况填写)。 保存文件