AWS EC2 problem: mysql wont connect with sqlalchemy on my flask app - mysql

I am a high school student trying to deploy a web api on EC2. I have been running into a problem where sqlalchemy (not flask_sqlalchemy) wont connect to mysql on ubuntu. I have typed in the password correctly, and am still getting:
Access denied for user 'root'#'localhost'
(Background on this error at: http://sqlalche.me/e/14/f405)
ubuntu#ip-172-31-3-251:~/deployedapp$
My code is:
engine=create_engine("mysql+mysqlconnector://*username*:*password*#localhost/*dbname*")
Any help is appreciated!
Thank you,
A confused high school coder.
EDIT:
This might have something to do with the problem. mysql -u root -p does not log me in. It says access denied. If I put sudo in front, it works.

I needed to create a new user and grant al privileges on the database to them.

Related

AWS Lightsail to external mySQL connections failing

I created a new instance (bitnami WordPress) in AWS Lightsail. Everything works fine. I am trying to connect to an external MySQL server (outside of AWS) from this Lightrail instance.
I am using the command:
mysql -u user_name -h xx.xx.xx.xx -p
Unfortunately, I am receiving this error message. I am unsure why the Lightrail instance resolves the external IP (outside of AWS) to the local Lightrail instance.
ERROR 1045 (28000): Access denied for user 'user_name'#'ec2-xx-xx-xx-xx.us-east-2.compute.amazonaws.com' (using password: YES)
I have performed an extensive search and could not find any similar issues.
FWIW, I have tried to add skip_name_resolve to the my.cnf file in vain.
I hope someone has run into this situation and was able to find a solution.
I could open a ticket with AWS; however, given that I have a basic account, I cannot place any support calls with AWS. I appreciate your help in advance.

ERROR 1045 (28000): Access denied for user 'root'#'localhost' (USING PASSWORD = NO) issue Freeradius server causing aborted connexion

Hi I'm trying to get a mariadb/freeradius/daloradius server up but i keep getting this log from systemctl -xe on my mariadb/mysql service, i came across that after figuring it was the sql connection that was problematic, freeradius shows me the same :
I'm getting frustrated, i ran across almost every config file, all should be in order but no this keeps happening, the radius server is trying to connect to my root sql user when i pointed to him in his config file that he should use the one i created especially for him and i can't manage to understand why, do mariadb needs the root credentials before even allowing it to connect to it ? I'm clueless please help.
This message tell you. that either the credentials in your config is not ok or that root user is not authorized to login.
Best practice is to take your mysql config and try to connect with the mysql command:
mysql -h yourconfigurationhost -u yourconfiguration user -p yourconfiguration password yourconfigurationdatabase
Be shure doing this with your application user.

MySql Access Denied when running python app [Ubuntu 1604/NGINX/uWSGI]

I am trying to deploy a test python app on digitalocean for the first time. (Ubuntu 16.04, uWSGI, NGINX). I've added a user and granted all privileges (and triple checked privileges). When I try and run the app, none of my tables get created and when I check the mysql error logs I see: "Access denied for user 'user'#'localhost' (using password: NO)"
The app itself runs fine without errors. It's just that none of my tables get created so when I enter a flask route that has a database query I get the 500 error
In my uWSGI, when defining database, I have the following:
ENVIRONMENT=DATABASE_URL=mysql://user:userpw#localhost:3306/databasename
command i ran to install mysql:
sudo apt-get install mysql-server
What might I be missing? Its driving me crazy...
I followed this tutorial very carefully, but changed postgres to mysql:
https://github.com/CristianoYL/Tutorials/blob/master/How%20To%20Deploy%20Python%20App%20Using%20uWSGI%20And%20Nginx.md
No mention so far, but how about FLUSH PRIVILEGES?
I'm also assuming there is no password. Password "NO" (as in none provided). I would look at the users table to see if they are set or not. It might be easier to test from the mysql cli vs. HTTP 500 errors :)
I tried this as a comment first, but it said I need 50 rep. I'll edit this post until I figure out a better way...

sudo user doesn't have correct mysql permissions

I am trying to use wp-deploy (which makes use of Capistrano) to deploy my Wordpress site to a Digital Ocean Droplet. I think I have everything configured properly but when I try to run the ...
bundle exec cap staging db:pull
... I get an error
SSHKit::Runner::ExecuteError: Exception while executing as sudousername#xxx.xxx.xxx.xxx: wp exit status: 127
(username and IP changed for privacy of course). So I SSH into my droplet and try to just connect to mysql using
mysql -u sudousername -p
and get the following error...
ERROR 1045 (28000): Access denied for user 'sudousername'#'localhost' (using password: YES)
I think this is because sudousername belongs to the sudo group and that group doesn't have permission to manage the DB?
I was hoping to find one of two solutions:
Grant the appropriate permissions to sudousername so it can do what it needs to on the DB
Pass along a second username and pass with Capistrano for the DB user (I created a user with phpmyadmin when I setup the database for Wordpress). The thought here being that when Capistrano is already SSH'd in and trying to perform functions on the DB it would use this other username and password.
I have looked for a solution for a couple hours now but I am a server n00b and haven't been able to find anything (and probably not sure what I am looking for).
Is anyone able to help? Thanks in advance!
I have figured out what the issue was. wp-deploy was using my sudo users credentials to SSH in and execute some shell commands. One of which was trying to use the WP Cli tool which I didn't have installed. Once I installed the WP Cli tool the scripts SSH'd in and ran wp db export and does so as the correct DB user. Thanks to #JuanTomas for helping me narrow that down.
For those that are having the same issue I also had to grant my DB user permissions for "LOCK TABLES'. Also, if you are using Wordpress 4.4+ you need WP Cli version 0.24 minimum or there will be compatibility issues. Use wp --info to check what version you have.

access denied to mysql root after flush privileges

I'm battling with a strange issue here.
I am setting up an Amazon EC2 server, installed with Ubuntu Server 12 LTS, to serve our web app.
I installed mysql, and then had some issues with being unable to access with the root password I had set.
Suspecting a conflict with a possible default install (I thought I had checked), I completely removed mysql including the user.
Starting fresh, I set a root password which then worked. I set up phpMyAdmin, got that working, but then when trying to set a password for a user following an import,
I got "could not find row" error.
Upon some searching I found that 'FLUSH PRIVILEGES;' could help remedy the problem. So I went back into the server, logged into mysql as root, and performed the flush command.
I was then logged out of phpMyAdmin with an access denied error, and since then have been unable to log back into mysql on the server.
The full error is:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
I am quite confused, already spent a lot of time trying to find out what the problem could be. Any help would be much appreciated. Thanks in advance.
Ha! Use --databases and include only your DB:
http://dev.mysql.com/doc/refman/5.5/en/mysqldump-copying-to-other-server.html
This was caused by my data import being from a full mysqldump, which I did now know would contain all user tables including root, which therefore overwrote my root user.
I guess there is a way to prevent either the export or import of the mysql table somewhere.
Learn something new everyday, as they say..