I'm trying so hard to make connection to mysql, and so far I end up with this error :
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'dev'#'localhost' (using password: YES) in D:\Programs\Xamp\htdocs\series\dynamic\AtomCMS\setup.php on line 5
Could not connect because: Access denied for user 'dev'#'localhost' (using password: YES)
I've just started developing a new web based system and here is the code I used to make connection to the database. Any help is appreciated.
$dbc = mysqli_connect('localhost','dev','123','pouya')OR die('Could not connect because: '.mysqli_connect_error());
Sincerely,
In case you are using XAMPP then open the phpmyadmin interface using [localhost/phpmyadmin]
1) On selecting the database you want to access.You get an option on right having a tab called privileges.
2) You need to check whether the user exist.If not Create a user dev.If the user exist try to recreate as you may be using a wrong password.
You need to make sure that the dev user exists, and that they are granted access rights to pouya.
Related
I'm presently reading the book "Head First jQuery" and came across this bit of code :
mysql_connect('127.0.0.1', 'runner_db_user', 'runner_db_password')
OR die( 'Could not connect to database.');
mysql_select_db('race_info');
But since mysql_connect is deprecated, I decided to use mysqli_connect via
mysqli_connect('127.0.0.1','runner_db_user','runner_db_password','race_info')
or die('Error connecting to Database');
However I get an error saying
Warning: mysqli_connect(): (HY000/1044): Access denied for user 'runner_db_user'#'localhost' to database 'race_info' in E:\wamp\www\Z_jquery\ch9\service.php on line 2
I created the user 'runner_db_user'#'localhost' and a database for it to use, using:
create database race_info;
CREATE USER 'runner_db_user'#'localhost' IDENTIFIED BY 'runner_db_password';
GRANT SELECT,INSERT,UPDATE,DELETE ON race_info.* TO 'runner_db_user'#'localhost';
I've confirmed using phpMyAdmin that both the user exists and it has the privileges granted by the above commands. Why then am I not able to connect to the database?
NOTE : I also was able to manually connect to the database using said login credentials via command line:
mysql -u runner_db_user -p
Why am I then unable to connect to the database via mysqli_connect()? Are there any further permission that I need to provide to the user to connect successfully?
EDIT : This is the present condition of my users. Are there any anonymous users that may cause this problem, according to the best answer here? If so, how do I delete these users?
I have setup a MySQL database and I am trying to connect to it from another website.
I get this error when I try to connect to it:
Connection failed: Access denied for user 'myUsername'#'localhost' (using password: YES)
It works fine when I do it in the same website where the database is hosted.
I tried this SQL query:
GRANT SELECT, DELETE, UPDATE ON database.myDatabaseName TO 'myUsername'#'localhost' IDENTIFIED BY 'myPassword';
But I got this error:
#1142 - SELECT,UPDATE,DE command denied to user 'Steve'#'localhost' for table 'myDatabaseName'
I went to the MySQL management in the built-in control panel where I modified permissions of Steve and added the Grant permission, however I still get the same #1142 error.
How can I fix this?
Thanks in advance.
Access denied for user 'myUsername'#'localhost' (using password: YES)
That's where the error is. It says you are attempting to connect to localhost with the username myUsername and a supplied password. However, usually on localhost, especially on windows systems, the user is Root and the password is not set, just an empty string. Check your username on your localhost and your password.
I am developing php site using xampp and I am having trouble accessing my MySql database.
I get the following error:
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'guest'#'localhost' (using password: YES) in C:\xampp\htdocs\Clothing\index.php on line 24
Here is the php code to connect to the database:
$conn = mysqli_connect('localhost', 'guest', 'Change01&', 'clothing')
All the credentials such as username and password are definitely correct, I have reset the password in phpMyAdmin about a thousand times and I still get the error. I have also made sure the guest user has all permissions set. What else could be the problem here ? It might be worth mentioning that I have changed the default ports for Apache but not for MySql.
I have a PHP file called footer10.php that worked just fine in shared hosting. I moved it to a virtual server and it no longer works.
I get these errors when I pull the file up in a browser:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'apache'#'localhost' (using password: NO) in /var/www/.../...com/httpdocs/.../footer10.php on line 23
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /var/www/.../...com/httpdocs/.../footer10.php on line 23
Access denied for user 'apache'#'localhost' (using password: NO)
This is on line 23 of the file:
$presult = mysql_query("SELECT COUNT(*) FROM submission") or die(mysql_error());
Any idea what I need to do to make the file work on the virtual server?
Thanks in advance,
John
The error message means that PHP could not connect to the MySQL database.
If you're establishing the connection on your own using mysql_connect you should make sure that host, user and password are correct (according to the error message no password was specified)
The user name and the empty password makes me think you've relied on the mysql.default_* settings on your old server. You can specify a default server in your php.ini, refer to the manual for this. The connection will then be opened automatically by php.
So what you have to do is to find out correct credentials for your MySQL server. Then you either establish a connection using mysql_connect/mysql_pconnect or add it to the php.ini.
Access denied for user 'apache'#'localhost' (using password: NO) , what does this line mean ?
It means you need to update you're mysql connection settings with the correct ones ( username , password and host ) by this i mean you're mysql connection settings on the new server are different than the ones on the old server . Then make shure to move the database from one server to another .
I have installed php5 and mysql5 on my server , I can login to mysql from command,
but when I try to connect using php I got this error message:
Access denied for user 'root'#'localhost' (using password: YES)PHP Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'#'localhost' (using password: NO) in D:\HostingSpaces\law-training\lawtraining.ir\wwwroot\includes\class.php on line 279 PHP Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in
I dont use 'ODBC'#'localhost' in my code at all.
I check using phpmyadmin , also I can't use it and can't connect to server.I use port 3309 for mysql , and from local or remote php can't login.
I use also mysql4 on this server on port 3306 and I can use it without problem.
how can i fix this problem?
Thanks
Try logging in to localhost:3309, I think you'll find that you're running it on a non-standard port, so you need to tell PHP where to look for the server.
ie.
mysql_connect("localhost:3309", "root", "mypassword");
As a sidenote, the ODBC#localhost connection is what mysql_query tries to use if there's no connection already open.
Is this a brand new MySQL 5 installation, and you have no means to log into it? You may want to reset the root password.
http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html
That should enable you to access MySQL using the command line. Then, make sure you have a root#localhost user and grant the relevant permissions to that user. For example:
mysql> GRANT ALL PRIVILEGES ON . TO 'root'#'localhost'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
If the problem persists with odbc connections, make sure your odbc data access product is fully compatible with your version of MySQL 5.x
Regards,
Netrista Khatam
Technical Services Manager
OpenLink Product Support