MYSQL error: 1045 (28000): Access denied - mysql

ruby on rails mysql production replication
This project is a cloned repo I want to be able to duplicate the production file for mysql database locally. I can run the application but, I'm missing a lot of assets. I have listed a few resources about the contents of the application below. Please let me know if I need to add anything else to better help you help me. Thanks
I have taken a look at this thread.. I ran all of the the commands as root, so I don't think that link applies to this issue.
.bash_profile
export HUB_test_DB="hub_test"
export HUB_test_USER="hub_test"
export HUB_test_PASS="whatevs"
export HUB_DEV_DB="hub_development"
export HUB_DEV_USER="hub_development"
export HUB_DEV_PASS="whatevs"
Mysql commands
mysql -u root -p THEROOTPASSWORD 28
CREATE USER 'hub_test'#'localhost' IDENTIFIED BY 'whatevs';
CREATE USER 'hub_development'#'localhost' IDENTIFIED BY 'whatevs';
grant all privileges on hub_test.* to hub_test#localhost;
grant all privileges on hub_development.* to hub_development#localhost;
flush privileges;
The test db isn't really used yet.
Command to duplicate database
mysql -u $HUB_DEV_USER -p $HUB_DEV_DB < db/backup/production-backup-latest.sql
Mysql> show databases;
Database
-information_schema
mysql
performance_schema
test
Users and Privileges

Related

Trouble Restoring MYSQL Database on CentOS Using SSH

I just had to change [dedicated CentOs] servers at Godaddy.
After I uploaded my .sql database backup file to the site using FTP, I connected to my site using SSH.
After changing to super user using the su - command, i tried using the following code to restore my database:
[root#sXXX.XXX.XXX.XXX ~]# mysql -u alaskasl_destiny -p alaskasl_freakout < /home/alaskasl/backup/databases/alaskasl_freakout.sql
I get the following ERROR 1044 (42000): Access denied for user 'alaskasl_destiny'#'localhost' to database 'alaskasl_freakout'
I can't figure out what I am doing wrong. This command has always worked for me in the past
First and foremost, if alasas1... is your real username, I would replace it with 'username'. Never give that info out, especially on a public place like Stackoverflow.
That said, a few things to check
1. You need to know the root user's login credentials for this new mysql instance. If this is a new setup the user is root with no password, so you should be able to use the following command:
$ mysql -u root
Once you do get in to mysql, you will see a prompt similar to:
mysql>
at that prompt you can type
mysql> show databases;
and a list of databases will display. Does the database you expect to be in there in there?
if not, here is what you need to do:
mysql> CREATE DATABASE 'database_name';
mysql> CREATE USER 'username' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON *.database_name TO 'username';
mysql> exit
At this point what you did was create the database, create a user with a password in mysql, and granted access to that database for that user. Once you type exit, you should now be back at the command prompt.
Now you can run mysql -u username -p database_name < /path/to/sql_file.sql

Database back-up as cronjob

I use this command to create .sql files of all tables in a huge mysql database:
mysqldump -h localhost --user=username -p --tab=/var/tmp database_name
The command above works perfectly but is prompting for the password.
Before i run this command i need to run:
GRANT FILE ON *.* TO 'username'#'%'
otherwise i get the error:
Got error: 1086: "File '/var/tmp/a_ab_text.txt' already exists" when executing 'SELECT INTO OUTFILE'
a_ab_text is the first table of the database.
Is there a way to get around this as I need to create a script that can be daily run as a cronjob.
To be clear a need a way to have the password in the script but typing the password after the --password '********' does not work.
And i need a way to overwrite the tables every day as we export all tables daily to a local server giving timestamp to the back-up file in order to have a dayly back-up version.
And of course i need a way to get around the command GRANT FILE ON *.* TO 'username'#'%' and restart the mysql server.
Thank you

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.

Restore root access to MySQL on Drupal Server

Context: I am new to Drupal. I am working within the Acquia Development App environment. After I was done with the Drupal installation process, I imported a database that I wanted to work with (from a safe tutorial). When I tried to see the site after the db import Drupal gave me an error message that it could not find the database.
Problem: I went to phpadmin to check what was going on and after trying some things I accidentally deleted all users, including the root. Now I am trying to start a new Drupal site installation from scratch with Acquia but I get the following message: "MySQL Error:Access denied for user 'root'#'localhost' (using password: NO)".
I have no idea how to regain access to MySql and restore my root user
Here is the sequence of steps on the Acquia App:
Any help is welcome.
Thanks!
If you deleted a user account in mySQL, you can recreate it using a SQL command
CREATE USER 'root'#'localhost' IDENTIFIED BY 'some_password';
Then grant permissions to the new user
GRANT ALL ON *.DB_NAME TO 'root'#'localhost' IDENTIFIED BY 'some_password';
FLUSH PRIVILEGES;
You should reinstall Acquia DevDesktop as this will re-configure the local MySQL installation. You won't be able to authenticate (as no root user exists for which you have credentials) with MySQL to update the root account as otherwise suggested.

MariaDB on Linux | Access .sql database

I'm self learning SQL. I've completed the SQLzoo course and wanted to get my hand dirty using a free Microsoft test database and MariaDB as client.
I've downloaded the database and saved it on the following path:
/usr/bin/northwind_mysql.sql
To access the database I've tried the following command but
gianluca#gianluca-Aspire-S3-391 ~ $ mysql -u gianluca -p -h localhost northwind_mysql
Enter password:
ERROR 1044 (42000): Access denied for user 'gianluca'#'localhost' to database 'northwind_mysql'
What I'm doing wrong?
Is there any clear Getting Started guide somewhere for people who don't have any experience with SQL?
I'm using it at work (MS SQL Server 2008), but I'm only querying the database with simple reading script. I would like to start learning more, for instance how to start it.
Thank you in advance.
I ran the following steps and connected successfully.
Verify connect as root
mysql -u root -p
mysql> show databases;
mysql> exit;
Download the Northwind database
Get it from here: http://code.google.com/p/northwindextended/downloads/detail?name=Northwind.MySQL5.sql
Set up the Northwind database as root
mysql -u root -p < Northwind.MySQL5.sql
Add gianluca as a user and grant permission to northwind
CREATE USER 'gianluca'#'localhost' IDENTIFIED BY 'whatevs';
GRANT ALL ON northwind.* TO 'gianluca'#'localhost';
FLUSH PRIVILEGES;
exit;
Connect as gianluca and access northwind tables
mysql -u gianluca -p
show databases;
use northwind;
show tables;
Notice that once you have created a username on localhost you don't have to specify it when connecting.