sudo user doesn't have correct mysql permissions - mysql

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.

Related

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

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.

Cannot preform mysql query from ubuntu terminal

What I'm trying to do:
I have a Minecraft server, I'm trying to my an admin panel so the other admins can help out the server more closely.
Right now, I am trying to make a live console. My thought was is that if I have a script fire off every 10 seconds the script would perform a MySQL query and upload the log file contents to the Database and then on the webpage is would display the rows.
What I have tried:
So I looked on StackOverflow and you can query MySQL databases from the Ubuntu terminal and I have tried that.
mysql -u username#Database -pPassword -h azure.database.for.mysql.url -P 3306 -D SchemaName
It does not work as I get an error
ERROR 1045 (28000): Access denied for user 'username'#'machineIp' (using password: YES)
There were people saying to edit the configs and comment out "bind-address" however it seems to only apply to the machine the MySQL server is on, and not the one performing the queries.
Things to note:
The Web Server, Minecraft Servers, and MySQL Server are all on different machines.
The MySQL server is a SaaS provided by Azure.
I use this database for my web server and it works fine in connecting to the server so I believe it is not a MySQL server issue.
I also use this database for my Minecraft permissions plugin and it connects fine.
If you have more questions please ask and I will do my best at answering them.
It looks like its not accepting your password.
This is the format that I use to access mysql from terminal.
mysql --prompt="(\u#\h) [\d]> " --user=your_username --password your_password

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

freePBX CDR on remote database failing to connect

Morning all,
I have just finished a fresh install of freePBX and am trying to get the CDR to use a remote database without any luck.
I have tested the connection to the remote DB using mysql -u USERNAME -h REMOTE_IP -p'PASSWORD' and it connects fine. However when I try to get the CDR to work it fails out saying access denied to the user.
I have used the 'Advanced Settings' to change the remote CDR DB details and this has done nothing, I have also edited the amportal.conf and the odbc.ini and still nothing.
What the hell am I missing, I really need to solve this quick if I can.
Cheers,
Blinky
You need to give database permission to remote user:
grant all on your_database.* to username#'remote_ip' identified by 'password';

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.