Okay so heres the situation. I have just had to move servers due to budget cuts so the new server is a webfusion VPS. I am now getting an access denied error on all mysql queries. This is the specific error:
Access denied for user 'www-data'#'localhost' (using password: NO)
I do not know what is causing this. I have a database with the mysql username and password stored in a different php file. The username shown in the error is not the same as the actual ussername and I am using a password. It is my understanding that you can put your own php.ini file in the webfusions root and that will work. Is there something I have missed? I have been running on coffee today so that could be why. The mysql database is on the same server btw.
It could be a couple of things. I guess let's start with what is correct.
Your MySQL server address is correct and your webserver is able to connect to it. This should be a given since your webserver and MySQL server appear to be on the same machine.
The username you are using is www-data. That is the first thing I would check. Make sure that is the proper username.
Now check your password. It looks like you are trying to not have to use a password. Chances are that is incorrect (and if it is correct, you really should think about changing that).
Other than that, there is not much else that could be going wrong there. Are you intending to connect to the MySQL server that is on the same machine as your website?
Did you create the appropriate MySQL users after you migrated the database? Grant tables and user privileges are usually not transferred while doing a DB migration (unless you are using some specific tools like the ones provided by Percona etc.)
Related
Someone sold us a script and not sure if it's working so I need to test it before it's too late however I'am getting the error "#1044 - Access denied for user 'root'#'localhost' to database 'information_schema'"
I wasn't able to put the code entirely so here is the pastebin link : http://pastebin.com/P4dPRHaf
I searched but couldn't really find a lot of help since i don't have experience on those stuff .note that I'am using Wamp server & getting this error when I try to import the .SQL file on PHPmyAdmin I guess that information_schema already exists on the database however not sure what part should I delete etc...
It's saving you from yourself.
You should not be running statements on the info schema db (unless you REALLY know what you're doing). The database serves as a "meta" repository that dictates how the server operates. Chances are that you have no need to touch it and you'll likely brick your server if you do.
I just installed an instance of Drupal on a shared web hosting account earlier today (via softaculous). I set some things different from how I wanted it the first time, so I deleted the directory it installed in, and the database and user that were created for it, and then tried again. Shortly after starting to work with the second install, I got the error described below, and I hadn't done much yet so I re-installed again. Now I'm on my third install, with all three using the same database and user name (I deleted the old MySQL database and user through cPanel before each install), and the same error is happening again.
When I try to access any of the drupal pages, I get this:
PDOException: SQLSTATE[HY000] [1045] Access denied for user
'mareofni_twocit'#'localhost' (using password: YES) in
lock_may_be_available() (line 167 of
home/mareofni/public_html/twocities/includes/lock.inc).
The "MySQL Databases" section of cPanel says that the database and user still exist. When I use the "check database" feature, it gives this error message:
Error from MySQL query: DBD::mysql::db do failed:
Unknown database 'mareofni_twocit'Failed to use
mareofni_twocit: Unknown database 'mareofni_twocit'
"Repair database" in cPanel doesn't fix the problem, and gives the same error message.
Error from MySQL query: DBD::mysql::db do failed:
Unknown database 'mareofni_twocit'Failed to use
mareofni_twocit: Unknown database 'mareofni_twocit'
I tried looking at the databse in phpMyAdmin, but phpMyAdmin doesn't list the database - like it can't tell that it exists.
Is there anything I can do to fix this problem myself, or prevent it happening again the next time I install Drupal? Some insight on what the problem is would also be helpful.
(Line breaks in the error messages are mine, added for readability.)
I've figured out that I cannot create database users who are able to drop databases, and the user I access phpMyAdmin through also cannot drop databases. Since phpMyAdmin couldn't find the database at all, I think the database must have been dropped or corrupted (rather than all the tables dropped or something).
This can't be something that Drupal did, since the Drupal user didn't have permission to drop the database. (Unless Drupal managed to corrupt the database somehow; I don't know enough about how that works to be sure of whether it's possible.) I suspect there's a bug in cPanel, Softaculous, or some other software put there by the hosting company that caused it. Maybe it didn't like that I re-created the DB immediately after deleting it.
I'm trying again with a different database name and crossing my fingers.
I am fairly new to web dev and I am in need of help trying to find out what the problem is. I had an install of MySQL 5.6.10 and I was given a task to update the src of a website that is currently live for past 5 years. None of the code has changed and it works for the other devs local machine. The server is running 5.0.51b and I just downgraded to 5.5.30 trying to get a syntax error to go away. The error was the SET OPTION SQL_BIG_SELECTS=1 was deprecated to SET SQL_BIG_SELECTS in a certain version. I am unable to change the syntax due to the version the server runs. So I chose to down version to 5.5.30.
My problem after the down grade is:
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user
''#'localhost' (using password: NO) in C:\Program Files (x86)\Apache Software
Foundation\Apache2.2\htdocs\****\src\www\include\func\func.db.php on line 47
I use MySQL Workbench for my connections none of the connections or users have passwords associated with them. I have another project that is not live that works fine from the localhost. My vhost and host files all have the proper syntax for this to work (verified with the other project). This all worked properly and was able to bring up the pages through vhost just fine yesterday. I never had any issues with how it was all setup to pull the index page. The only problem was the MySQL version issues. What can I do to fix this problem? I have tried recreating connections in the workbench and even deleting all the instances and recreating them. I am stumped. Any help would be greatly appreciated.
You can see this error because you haven't connect your mysql database properly.
mysql_connect("HOST","USER","PASSWORD")
make sure the host, username and password is corrent
Was MySQL the only thing you upgraded? Any chance you upgraded PHP and now no longer have register_globals on? If you have it off and your colleagues have it on, this could explain the differences you are seeing.
http://php.net/manual/en/security.globals.php
Looking closely at your error you can see that it's telling you what is wrong (typically what error reports are for):
Access denied for user
''#'localhost' (using password: NO)
Looking specifically at:
''#'localhost'
^^
You see that no user was specified. You need to specify the user you wish to connect as.
mysql_connect("HOST","USER","PASSWORD")
Which comes before a mysql_select_db call.
MySQL Connect
& MySQL Select DB
NOTICE: Don't upgrade to PHP 5.5 for MySQL_* functions have been deprecated. I say this since you do not wish to change any code.
From what I am seeing in the error that has been returned, you did not pass the connection a username to use to connect to MySQL.
I have a problem with the MySQL root user in My MySQL setup, and I just can't for the life of me work out how to fix it. It seems that I have somehow messed up the root user, and my access to databases is now very erratic.
For reference, I'm using MAMP on OS X to provide the MySQL server. I'm not sure how much that matters though - I'd guess that whatever I've done will require a command-line fix to solve it.
I can start MySQL using MAMP as usual, and access databases using the 'standard' users I have created for my PHP apps. However, the root user, which I use in my MySQL GUI client, and also in phpMyAdmin, can only access the "information_schema" database, as well as two I have created manually, and presumably (and mistakenly) left permissions wide open for. My 15 or so other databases cannot be accessed my the root user. When I load up phpMyAdmin, the home screen says: "Create new database: No Privileges".
I certainly did at some stage change my root user's password using the MAMP dialog. But I don't remember if I did anything else which might have caused this problem. I've tried changing the password again, and there seems to be no change in the issue.
I've also tried resetting root password using the command line, including starting mysql manually with --skip-grant-tables then flushing privs, but again, nothing seems to fix the issue.
I've come to the end of my ideas, and would very much appreciate some step-by-step advice and diagnosis from one of the experts here!
Many thanks for your help.
I had the same issue: only one user account worked to access the mysql databases via the administration console or the query browser. When I used the skip-grant-tables suddenly all accounts could log in, including root.
I saw it as a bug as far back as 2006, but the final entry there isn't a command that can be executed when in skip-grant-tables mode, so I still hadn't solved the issue.
What helped me
This answer is similar to one described by Ben Bakelaar in the above link. The problem comes when your my.ini has the name resolution flag disabled (skip-name-resolve). This kills mysql's ability to resolve 'localhost' and the mysql.user table only has an entry for localhost / root.
Update your mysql.user table's localhost entry to be 127.0.0.1 instead, and you can log in to the local consoles even with the skip-name-resolve feature enabled.
Try starting the server with --skip-grant-tables and then checking the privilege tables in the mysql database:
select * from user where User='root';
select * from tables_priv where User='root';
select * from db where User='root';
You could also try:
show grants for root#localhost;
show grants for root#'%';
show grants for root#'hostname';
Once in you could do this to attempt to give root full privileges:
grant all privileges on *.* to root#localhost identified by 'password' with grant option;
Your comment shows your current root privileges (without --skip-grant-tables). It's fine that you do not have any entry for 'root'#'%', you do not have that by default and you can consider it a security measure.
It looks like you've messed up your 'root'#'localhost' privileges. GRANT ALL PRIVILEGES ON . is weird. Usually, you have something like GRANT ALL PRIVILEGES ON *.* or GRANT ALL PRIVILEGES ON myDatabase.myTable. Your GRANT does not specify the databases and/or tables to grant the privileges for. I have no idea how your client managed to produce it. I cannot reproduce it with the mysql commandline client (tried empty strings, whitespace, any kind of quotes...), mysql refuses the GRANT statement (which, of course, is the correct behaviour). Looks like MAMP is doing something really strange. Since I cannot reproduce a GRANT like yours, I cannot say how mysql interprets that, but I guess it has set the privileges to 'N' on the global level.
To fix it, you need a user with appropiate privileges. Usually, you have a user 'root'#'localhost' and a 'root'#'your-hostname'. If you're lucky, 'root'#'your-hostname' is still fine. Afair, mysql connections work as follows: If you connect to localhost, you connect as 'root'#'localhost' (not sure about 127.0.0.1, I guess it is also 'root'#'localhost'). If you connect to your-hostname, you connect as 'root'#'your-hostname'. If this user's privileges are still ok, you can update the privileges for 'root'#'localhost' and you are done.
In your comment, you say you cannot connect via 127.0.0.1 since the socket is in an unusual place. I guess you misinterpret the error. IIRC you connect via socket if you connect to 'localhost', but via TCP/IP if you connect to 127.0.0.1 or your-hostname. If mysql tries to connect via socket and cannot find the socket (because you did not specify the correct location), the error message mentions where mysql tried to find the socket. Your error message does not. I guess your error is a networking error. Maybe you've started the mysql-server with the --skip-networking option, or your configuration specifies an incorrect bind-address. You need to fix that first, otherwise you can't connect as 'root'#'your-hostname'.
Thats because MAMP and the command line mysql (and the mysql everything except MAMP) are different.
MAMP has its own built in mysql and you can't get to it via the command line, only the build in phpmyadmin.
this has been my experience, I have MAMP and use the other mysql for ruby on rails and other stuff.
had a bit of confusion going around in work earlier. Thought id run it by yous to see if anyone knows wats going on.
Were working on an internal administration system for our client, and its rite about to launch. Its comprised of TWO MySQL databases on the server [db_1 and db_2] and a PHP front end. [Both databases contain several tables].
There are maybe 90 different PHP files, some of which require a connection to our databases and ALL of these connections are made via a single PHP function which explicitly connects to the first database mentioned above [db_1] and supplies the login and password. And this works fine.
However, our second database, db_2, does not seem to require its own login and password to access its contents.
As soon as we connect to db_1, we seem to have full access to db_2, as long as we use the Full-Name for our tables [ie: db_2.usersTable] -> ("SELECT * FROM db_2.usersTable WHERE...").
And this is what was causing much confusion.
My question is this: Once you connect to a database on a server, do you have access to other databases on that server, or are we overlooking something???
Any feedback greatly appreciated lads...
You usually don't access a database server by a specific database, but by a user that has access to one or more databases.
for example:
mysql_connect("localhost", "user", "password") or die(mysql_error());
connects to the server and not a specific database.
Once connected to the database server you have access to all databases for which that user has permission. You just need to specify the database name in your queries if there are multiple databases that aren't the default.
mysql_select_db("myTable") or die(mysql_error());
sets myTable as the default, but you can still access other tables that the user has permission to.
I might be wrong, but doesn't PHP only connect and authenticate with the MySQL server with a user? And thus, based on that user's permissions, PHP can select any database that user has access to. I would check the permissions for the user you are connecting with...
Once you connect to a database on a
server, do you have access to other
databases on that server
If you have permissions to other databases, then yes. When you connect, you're connecting to the server and setting your default database to the one specified. Which is why you have to explicitly specify db_2 when you want to access it, but you don't have to specify db_1.