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

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...

Related

Access denied for user 'root'#'localhost' immediately after install

I have a brand new Mac running Mojave. I've installed MySQL multiple times on my older Mac and never had a problem. But this install, for whatever reason, isn't getting off the ground.
I have installed MySQL and started the server. At this point, all I wanted to do was verify the version from the command line, and this is what I get:
> mysql -v
ERROR 1045 (28000): Access denied for user 'milnuts'#'localhost' (using password: NO)
> mysql -u root
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
I've scoured the plethora of other posts, this one being the closest, but almost all solutions require actually being able to connect to MySQL as root. I can't even do that. I never specified a password during the install process, so what am I missing here? Is there some new config in Mojave somewhere that I don't know about?
Try using MySQL Workbench. You can install it on their site, or if you are using homebrew (which I strongly recommend), simply brew cask install mysqlworkbench.
You might need to try reinstalling mysql. This can be a pain if you didn't install it using homebrew. But, if you did, you can simply brew uninstall mysql then brew install mysql.
homebrew makes permission problems like these almost non existent! Honestly you should install literally everything using it.
I finally got this working. With the latest version of MySQL, v8.0.15, (and maybe before as well), during the configuration step it asks you to configure the server using one of two options.
Use Strong Password Encryption
Use Legacy Password Encryption
The first four or five times I installed, I selected option #1 which says...
MySQL 8 supports a new, stronger authentication method based on
SHA256. All new installations of the MySQL Server should use the this
method.
Connectors and clients that don't support this method will be unable
to connect to MySQL Server. Currently, connectors and community
drivers that use libmysqlclient 8.0 support the new method.
On my last install, I selected option #2. That seemed to clear up all the problems I was experiencing. So it obviously had something to do with the authentication process.

mysql cant log in as a regular user using root, same as phpmyadmin

I installedd LLMP on default, fresh Linux Mint 18 Mate install. Everything is updated and pretty fresh. Then the strange problem occured with logging into the database.
My exact steps:
1. Installed lighttpd. It crashed until I installed also gamin package, then it works.
Installed php7 with php-mysql
Installed mariadb-server
Run mysql_secure_install, defined new root password, answered all Y for deleting test db, disabling anonymous accounts and disallowing root login from tcp, etc. Everything was suggested as a valid, default answer.
Installed phpmyadmin, this fails on post-install, but running apt-get install -f repaired it and finished install correctly.
WTF1: Now, as root user I can login without password to mysql in the console.
WTF2: I can't login to mysql as a regular user, even when I give good password. It says "ERROR 1698 (28000): Access denied for user 'root'#'localhost'"
WTF3: I can't also login to database using phpmyadmin, using root account and proper password, when run on my localhost workstation via lighttpd.
What the heck is going on? My expectation was it should work out of the box, allowing me to login ONLY with root password either on CLI or via phpmyadmin. What is wrong?
I solved this and the answer is in the comment to the question.

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.

MySQL 5.6.26 (Windows 8.1 x64): Trouble with setting a password for the root MySQL user

I'm a newcomer to MySQL where I'm to learn on how to use it to build a database for a startup company, and it seems that I'm running into some trouble in learning on how to use it on Windows 8.1 x64. I've spent less than an hour trying to solve it on my own using Google and some questions already posted and answered here, but with no success.
In learning MySQL, I’m following along a series of YouTube videos my boss recommended that I follow and practice along. I went through the first video, but I would rather wait until I get my problem fixed up before I move on because I have a feeling I do need a root password for a tutorial that’s later on in this playlist.
The problem I’m having is setting the password for the root user and logging in. I’ve followed along this command from the “MySQL Installation” site on Command Prompt:
C:\Users\Gregory> mysqladmin –u root password “new_password”;
The error message it gives me is something like the following:
mysqladmin: connect to server at ‘localhost’ failed
error: ‘Access denied for user ‘root’#’localhost’ (using password: NO)’
Here’s what I get when I type in ‘mysqladmin –version’:
Mysqladmin Ver 8.42 Distrib 5.6.26, for Win64 on x86_64
What I downloaded was MySQL Community Server 5.6.26 as a Windows x64 ZIP archive, since the tutorial my boss provided me asks to unzip the compressed folder instead of using an MSI program that I could have downloaded. There was no setup.exe in the bin folder, so I simply moved the files to a folder in the root of my hard drive called “mysql” and added an extra path to my existing Environment Variables so that Command Prompt recognizes what I’m asking for without having to call the “cd” command multiple times.
Even if I did try to connect the user to the MySQL server, I would get the following (here, I’m using the password “new_password” as an example since the tutorial I used have used it in their example of setting a new password to the root):
C:\Users\Gregory> mysql –u root –p
Enter password: ************
ERROR 1045 (28000): Access denied for user ‘root’#’localhost’ (using password: YES)
Since at one point I really was getting confused, before I tried focusing on this issue for half an hour, I had to reset the password using MySQL’s own password reset procedure.
If I type in ipconfig –all instead, this is what I get under the “Windows IP Configuration” header:
Host Name : GregoryDES-PC
Primary DNS Suffix :
Node Type: Hybrid
IP Routing Enabled: No
WINS Proxy Enabled: No
I do get the host name, but the rest of the information don’t make any sense to me whatsoever.
I even tried using this, along with ‘—password=pass’ from a StackOverflow question, to connect, except I still couldn’t get on.
From coming across the Telnet Client service from one DevSide Forums post that I decided to enable and investigate, here’s what I did and what I get in return:
C:\Users\Gregory> telnet 8000
Connecting To 8000…Could not open connection to the host, on port 23: Connect failed
I also tried “mysqladmin –uroot –pmysuperscretpassword proc” from another StackOverflow question that was answered:
Warning: Using a password on the command line interface can be insecure.
mysqladmin: connect to server at ‘localhost’ failed
error: ‘Access denied for user ‘root’#’localhost’ (using password: NO)’
Setting the host with the ‘—host’ option on mysqladmin and what I was given from ‘ipconfig –all’ has no effect on setting the password for the root user.
I can’t even fetch the actual root password from the MySQL program I have installed, because from a StackOverflow question, it involves using it to access it and reveal it from a database.
I can’t even start a MySQL server to see if this is needed for the root user to log in, as I show you in a photo:
Could you please help me out here?
What on earth was I thinking back there?
I simply decided to reset my password back to blank to the user using the same reset instructions I used before, tried logging in after entering the 'mysql' command with the options needed, and it actually worked. So I reverted back to the password I created before, and now I'm back on business.

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..