MySQL failing to log in for mysqldump - mysql

I'm trying to use mysqldump in my server, from the command line.
root#xxxxx:/xx/xx/xx/backups/09-03-13# mysqldump db_name_xxxx --tab=. --user=xxxx
--password=xxxxx
mysqldump: Got error: 1045: Access denied for user 'xxxxx'#'localhost' (using
password: YES) when executing 'SELECT INTO OUTFILE'
So I assume it's a problem with username/password.
However, I can get into the MySQL command line fine using mysql, with exactly the same logon details.
What could be causing mysqldump to fail, but not mysql?

Your problem is not with the login details but with the user you are logging in as.
In order to carry out a mysqldump you need at least SHOW DATABASES, SELECT, LOCK privileges on every table in the database. Things get more complicated if you use more exotic options such as locking etc.
This is a faily good reference for what permissions you need for what options in mysqldump.

Related

ownCloud Setup: SQLSTATE[HY000][1045] Access denied for user 'owncloud'#localhost' (using password:YES)

I wanted to setup my owncloud installation on my raspberry pi 2. So, I created an mysql database and user.
CREATE DATABASE owncloud;
CREATE USER 'owncloud'#'localhost' IDENTIFIED BY 'Password';
GRANT ALL PRIVILEGES ON owncloud. * TO 'owncloud'#'localhost';
FLUSH PRIVILEGES;
After I type all nessesairy parameters into the webinterface of the owncloud-setup, I recevied:
Error while trying to create admin user: Failed to connect the database: An exeption occured in driver: SQLSTATE[HY000][1045] Access denied for user 'owncloud'#'localhost' (using password:YES)
Sadly, my resent sreach on similar topics didn't result in any functional hint on this problem. So, I would be happy about further suggestions.
Look at this: https://doc.owncloud.org/server/9.0/admin_manual/installation/installation_wizard.html#database-choice
In Terminal: mysql_upgrade --force -u root -p
Use administrative MySQL »root«-user and password with the Installation Wizard
Check that the Database not exist which you create with the Installation Wizard
If nothing helps, start with sqlite, then migrate to mysql like this: https://doc.owncloud.org/server/9.0/admin_manual/configuration_database/db_conversion.html
Just replace localhost for 127.0.0.1 in Owncloud's setup form for MySQL as mentioned in comments above by Askaga
For some reason, explicitly re-access the database from the terminal solves the problem for me. Just give mysql an empty line with
mysql -u root -e ";"
This should be an individual command after you created database and database user.
Sure, you should always check whether
There are users with an empty username. Remove them.
Remove "test" database.
Grant appropriate permission to your database user.
Last but not least FLUSH PRIVILEGES;.
Search other posts for instructions. I'm just providing a possible solution if you come across a situation where none of the above works.
Here's a good example to properly setup mysql after installation. FYI.
Mask the DB password in the installation screen (the password should not be visible, only dots) and retry.
Ubuntu 18.04.1, Owncloud 10.
Check the contents of config.php in my case located at /var/www/owncloud/config/.
Specialy items dbuser and dbpasswrd.
Read config.sample.php in the same directory for info.

Access denied creating initial database- how do I grant the right access?

I'm making a new project on heroku, using mysql (they have an addon called JawsDB, which gives me a mysql host, username, password). (Update: I've also tried using their other mysql addon, ClearDB, and I have the exact same issue)
I can connect to the database like so (and I can 'show databases' to see what's there):
mysql -h izm96dhhnwr2ieg0.cbetxkdyhwsb.us-east-1.rds.amazonaws.com -u knu81lzn5m79u3rx -p[given_password]
Problem: When I do create database nptest, I get:
Access denied for user 'knu81lzn5m79u3rx'#%' to database 'nptest'
I've tried granting all privileges, like this:
grant all privileges on *.* to 'knu81lzn5m79u3rx'#'%' identified by '[given_password]';
but that gives me:
Access denied for user 'knu81lzn5m79u3rx'#'%' (using password: YES)
I also tried create user to make a fresh one, but of course then it's "Access denied" because I don't have create user privileges either.
What's the correct way to grant access to this user?
Ah! The answer was that the preliminary plan on jawsDB gives you one specific database (that has a cryptic name) on a shared server with other people, so you don't have permissions to make a new one. It wasn't clear in the instructions, so now I'm humming away with good old database "tbkrv66g085ulngi" :)
To further clarify on Diane's answer, the cryptic database name can be found by logging into JawsDB via a mysql client and runningshow databases or it's the last parameter of the JAWSDB_URL that can be found running heroku config.
i think if you use it in production mode it will solve the probl

Access denied for user 'ODBC'#'localhost'

I've looked everywhere an cannot seem to find a fix for this issue, despite tons of articles on it. Anyway, I'm attempting the following command
mysqldump -hlocalhost -uroot -p mydb mytable > myexportedtable.sql
This will occasionally result in the following error
mysqldump: Got error: 1045: Access denied for user 'ODBC'#'localhost' <using password:NO> when trying to connect
This is baffling for two reasons. One - I am specifying a root user in my command however it assumes I'm ODBC. Two - I only get this error occasionally. (more often than not). I am able to authenticate to the mysql interactive shell when specifying root but keep getting this error with mySQL dump. Any insight is greatly appreciated as I've been trouble shooting this for days now.
Type in the command manually. Sometimes copying and pasting the command changes the hyphen character (-). It is ignoring the username because it literally doesn't recognize a -u.
This seems to happen when you connect with the wrong user to the database, wrong password usage or when you connect from the wrong host or over the socket/port when you are not allowed to.
I suggest checking the access privileges of the user like:
mysql> SELECT user, host FROM mysql.user WHERE user = 'jake';
mysql> SHOW GRANTS FOR 'jake'#'localhost';
Perhaps also take a look at mysqlimport: Error: 1045, Access denied , which helped me a lot.

ERROR 1045: Transferring SQL database from one server to another

I have taken the the following steps to transfer my sql database but yet I receive an error on the importing of the database onto the new server. It does not seem to recognize my username or password.
I think the problem is being caused by phpMyAdmin privilege settings. I am transferring my sql file from a server that runs phpMyAdmin (hostgator) to an unmanaged web server.
Here are the steps I took
mysqldump -u root_wrdp1 -p --opt root_wrdp1 > root_wrdp1.sql
Enter password:
I then scp'd the sql file to my new web server (that does not run phpMyAdmin).
scp rbl91_wrdp1.sql root#ip.of.the.server:~/
Then I did the updating of the database on the web server without phpmyadmin...
root#www:~# mysql -u root_wrdp1 -p root_wrdp1 < ~/root_wrdp1.sql
Enter password:
ERROR 1045 (28000): Access denied for user 'root_wprd1'#'localhost' (using password: YES)
The support by the site offered this advice but I have no idea how to implement the steps.
It's possible you have to review the authorization locations, such as the source location (IP) of the remote side.
Using phpMyAdmin i believe the page is Priviliages , and you will also
need to flush them after changing.
Thanks Support
It's a simple authentication problem. Most likely the "root_wrp1" account or password are set up incorrectly on the destination machine. You can check it just by trying to log in without importing the dump file:
$ mysql -u root_wrdp1 -p root_wrdp1
The account and password need to be set up and have adequate permissions to the database before you can restore the dump file.

Error 1142: SELECT and LOCK TABLE commands denied

I reinstalled the server running MySQL. I had created a backup of the database by using MySQL Workbench. Now I'm trying to import the dump in to the database trough the same program but I get the following error:
ERROR 1142 (42000) at line 656: SELECT,LOCK TABL command denied to user 'root'#'MIKKOS' for table 'events_waits_summary_by_thread_by_event_name'
I tought that root had full privileges. I ran the following but the same error appears with the previous query after executing this:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' WITH GRANT OPTION
It also appears when running locally (root#localhost).
What to do?
Check which databases MySQL Workbench included in the dumpfile. I believe it defaults to dumping everything, including DBs like user and performance_schema. Those are the problem, your grant tables are probably fine.
Remove the unneeded databases, especially performance_schema and MySQL will likely import the dumpfile without errors.
You need to repair internal table structure after reinstallation a newer MySQL server. To do so try:
REPAIR TABLE `events_waits_summary_by_thread_by_event_name`;
It would be better to drop database and restore it from full mysql database dump if you have one.