php access denied for user

Ошибка «mysqli_connect(): (HY000/1045): Access denied for user ‘username’@’localhost’» (РЕШЕНО)

При попытке выполнить вход phpMyAdmin или авторизоваться в MySQL вы можете столкнуться с ошибкой HY000/1045:

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

Ошибка возникает, когда используемая комбинация имени пользователя, хоста и пароля не позволяет подключаться к серверу. Например, если пытаться выполнить вход под пользователем, который не существует вовсе, то возникнет именно эта ошибка.

Давайте посмотрим на следующий код, который вызывает эту ошибку:

Увидели подвох? Устанавливается значение константы DB_USER, а используется для подключения DB_USERNAME, аналогично с DB_HOST и DB_SERVER. То есть в СУБД передаются неверные или пустые данные с которыми невозможно выполнить подключение.

Посмотрите на следующий код, который также вызовет ошибку:

В пароле содержится специальный символ $. В принципе, в пароле можно (и даже нужно) использовать специальные символы, но некоторые из них имеют специальное значение для языков программирования или для оболочки (если подключение выполняется в командной строке). Одинарная и двойная кавычки хотя и используются одинаково для обозначения строк чтобы символы в них перестали трактоваться как другие элементы языка, но они не являются идентичными. Одинарная кавычка делает так, что любые символы теряют своё специальное значение. А в строке, помещённой в двойные кавычки, некоторые специальные символы сохраняют своё значение. То есть «sdfasdf$B» интерпретатором PHP расценивается как буквальная строка «sdfasdf» за которой следует переменная $B.

Чтобы убедиться, что проблема в пароле содержащим специальные символы, вы можете временно установить пароль на не содержащий специальных символов примерно следующей командой:

В этом примере пароль установлен на «12345».

Создание нового пользователя при ошибке HY000/1045

Эта ошибка является вариантом рассмотренной ошибки — но разница в том, что необходимый пользователь действительно отсутствует и его нужно создать:

В данном случае это пользователь pma, но вы можете применять описанные команды для создания любых пользователей, заменяя в командах «pma» на нужное вам имя.

В терминале войдите в MySQL как root. Возможно, вы создали пароль root при первой установке MySQL или пароль может быть пустым, и в этом случае вы можете просто нажать ENTER, когда будет предложено ввести пароль.

Теперь добавьте нового пользователя MySQL с именем пользователя по вашему выбору. В этом примере мы называем его pma. Обязательно замените ЗДЕСЬ ПАРОЛЬ своим собственным. Символ % здесь указывает MySQL разрешить этому пользователю входить в систему из любого места удалённо (а не только с локального компьютера). Если вам нужна повышенная безопасность, вы можете заменить это IP-адресом.

Теперь мы предоставим нашему новому пользователю привилегию суперпользователя.

Источник

«Connect failed: Access denied for user ‘root’@’localhost’ (using password: YES)» from php function [duplicate]

I wrote some function used by a php webpage, in order to interact with a mysql database. When I test them on my server I get this error:

I am able to use them on my pc (using XAMPP) and I can navigate through the tables of the database using the command line in the server. However, the webpage fails to connect. I’ve checked the password but with no results. It’s correct (otherwise I could not log in to mysql from the command line).

The call of the function is the following:

Do I have to set something in my server? Thanks

Edit: PHP version 5.3.3-7+squeeze1 mysql version: 5.1.49-3 both on debian

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

11 Answers 11

I solved in this way: I logged in with root username

I created a new user with

then I created the database

I granted privileges for new user for this database

Then I logged out root and logged in new user

I rebuilt my database using a script

And that’s it.. Now from php works without problems with the call

Thanks to all for your time 🙂

Is there a user account entry in the DB for root@localhost? In MySQL you can set different user account permissions by host. There could be several different accounts with the same name combined with the host they are connecting from. The most common are root@127.0.0.1 and root@localhost. These can have different passwords and permissions. Make sure root@localhost exist and has the settings you expect.

I am willing to bet, based on your explanation, that this is the problem. Connecting from another PC uses a different account than root@localhost and the command line I think connects using root@127.0.0.1.

From what you’ve said so far, it sounds like a problem where the MySQL driver in PHP5.3 has trouble connecting to the older MySQL version 4.1. Have a look on http://www.bitshop.com/Blogs/tabid/95/EntryId/67/PHP-mysqlnd-cannot-connect-to-MySQL-4-1-using-old-authentication.aspx

There’s a similar question here with some useful answers, Cannot connect to MySQL 4.1+ using old authentication

This will return 16 for accounts with old passwords and 41 for accounts with new passwords (and 0 for accounts with no password at all, you might want to take care of those as well). Either use the user managements tools of the MySQL front end (if there are any) or

Источник

I want to set up and learn Laravel following this course

When I try to use the command php artisan migrate I get this error:

I’m using Ubuntu 16.04, not a Mac OS X as in the video, so I wonder what should I do differently? Is there some MySQL setting I did not set correctly?

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

21 Answers 21

I had never come across this problem before.

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

After you have changed the values, make sure to run the following two commands before you do anything else:

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

In my case it solved with using localhost instead of 127.0.0.1

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

Faced the same problem. Updated my root password in mysql using

I had the same issue. What finally worked for me was performing Method 2 on this page.

Through my struggle, I learned that there are 4 different places where you can set a password for the root of the MySQL installation that comes with XAMPP. Setting the password in only 1 or 2 of these places alone is not enough. This is what I did to be able to perform my initial migration:

And then restart MySQL and your web (Apache) server.

Be aware that after you successfully harmonize your passwords and try once again to migrate, you may get error output that looks almost the same as the Access Denied password error. However, this is a different error related to string lengths. See here for how to fix that issue.

Источник

phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user ‘pma’@’localhost’ (using password: NO)

I keep getting the following errors with mysql connection through XAMPP and I don’t know what to do:

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

That’s the code in the config.inc.php

I’ve already reset the password from MySql from the command line two times and added the changes to this code above and to the php.ini file, but at each time it goes back to the error. Any help?

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

18 Answers 18

yo need create the user «pma» in mysql or change this lines(user and password for mysql):

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

Add this line to the file xampp\phpMyAdmin\config.inc :

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

In terminal, log into MySQL as root. You may have created a root password when you installed MySQL for the first time or the password could be blank, in which case you can just press ENTER when prompted for a password.

Now add a new MySQL user with the username of your choice. In this example we are calling it pmauser (for phpmyadmin user). Make sure to replace password_here with your own. You can generate a password here. The % symbol here tells MySQL to allow this user to log in from anywhere remotely. If you wanted heightened security, you could replace this with an IP address.

Now we will grant superuser privilege to our new user.

Then go to config.inc.php ( in ubuntu, /etc/phpmyadmin/config.inc.php )

/* User for advanced features */

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

Add these lines to the file xampp\phpMyAdmin\config.inc :

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

My default 3306 port was in use, so Ive changed it to 8111, then I had this error. Ive fixed it by adding

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

Linux / Ubuntu: If installed phpmyadmin via apt: sudo apt-get install phpmyadmin php-mbstring

Can check /etc/phpmyadmin/config-db.php for changing the user credentials.

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

The Connection for controluser as defined in your configuration failed, right after:

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

I solved the problem by adding the line skip-grant-tables to the my.ini:

Under XAMPP Control Panel > Section «MySQL» > Config > my.ini

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

I experienced the same errors on a fresh install of VestaCP. I solved the issues by following the instructions on this video.

php access denied for user. Смотреть фото php access denied for user. Смотреть картинку php access denied for user. Картинка про php access denied for user. Фото php access denied for user

Basically, the problem is PMA is trying to connect to SQL with a user that doesn’t exist.

You might also change other stuff there, like the server address ($dbserver), the port ($dbport, which might not be the default one on your machine), and more.

Источник

Warning: mysql_query(): Access denied for user ‘admin’@’localhost’ (using password: NO) [closed]

Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

It seems as though my PHP is trying to log in to the MySQL database with a username I am not supplying.

The error I am getting is:

I am definitely supplying a password, and am not using «radiocaf» as the username in my connect file, so after 3 hours of staring, I still can’t work out where I am going wrong.

psl-config.php:

db_connect.php

and then finally, the main page which is where I am receiving the error (I have cut out the HTML between the PHP:

The surrounding HTML is just the layout of the page, essentially just a photoshop layout, sliced and exported to web.

I am fairly new to PHP and so I hope this question is as explained as possible.

Thanks so much guys, I apologise that this question seemed poor to some of you that you flagged it. Unfortunately I wouldn’t have seen the «typos» as I really didn’t know that I was attempting to use both mysql and mysqli and that they couldn’t «communicate» with each other. Another issue I found was Dreamweaver uploaded the code from layout.php as db_connect.php. This doesn’t explain (to me at least) how any connection was being made to bring up the access denied error for ‘radiocaf’@’localhost’ though.

Here’s the old code lines I changed (in layout.php):

And that’s all it took, but I am entirely grateful! Thanks again everyone!

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *