Cannot preform mysql query from ubuntu terminal - mysql

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

Related

Can't get my azure sql server up and running

I'm getting crazy over this issue, I hope someone can help me:
I created an Azure Database for MySQL server
Disabled SSL, and allowed all IPs to access
Trying to connect to the server using Server name and Server admin login name
I tried MySQLWorkbench, and CLI mysql -u <Server admin login name> -h <Server name> -P 3306 -p
In both cases it freezes, no error messages, doesn't timeout, no logs on the azure side.
I have literally no idea what's wrong or what to do about it. The database was just created, totally untouched.
Has anyone experiences something similar before?
Thank you!
With the given information it's not clear what is the exact error while accessing the database, but if you have deployed it properly you can access it easily without any error using both, MySQL Workbench and CLI.
In your example, the sequence of parameter isn't in write format which might giving issue.
Try below format:
mysql -h <server_name>.mysql.database.azure.com -u <admin_name>#<server_name> -p
If using MySQL Workbench, you can refer official document Use MySQL Workbench to connect and query data in Azure Database for MySQL for the same.
This should work.

Remotely Accessing MySQL on Mac Mini/Time Capsule

I'm currently trying to run an application on a server but my customer is very 'picky' about their data and wish to store the database on their own internal office server. I've installed MySQL and can get the application to run locally but for a few specific reasons the application needs to run else where.
I basically can't get access to MySQL from a different location. I think my main stumbling block is port forwarding to the correct location. MySQL is installed on a mac mini with local IP address 192.168.1.242 and the router/modem is an Apple Time Capsule. I've tried looking at tutorials but they all have options that I don't have access to. I've attached a screenshot of the options I have access to and the settings I've tried so far.
Other information possibly needed is:
I need to connect from PHP
I've set a user up within MySQL with a wildcard (%)
I'm testing it using the following: command on my local machine in CMD: mysql -u username -h remote_ip_address -p
I get the following error: ERROR 2003 (HY000): Can't connect to MySQL server on 'REMOTE_IP_ADDRESS' (10061)
Firewall is turned off completely on the Mac Mini
There is nothing in the my.cnf file
OS is Sierra
That's all I can think of at the moment but any advice would be greatly appreciated and any more information required can be provided.
PS. evidently I'm not very good with MAC machines/networks
For anyone that reads this I had a very specific issue. I installed MySQL using homebrew. Homebrew binds MySQL to 127.0.0.1 therefore will only allow connections to MySQL from the same machine no matter what you try to do. To fix it I've had to edit /usr/local/Cellar/mysql//homebrew.mxcl.mysql.plist and replace --bind-address=127.0.0.1 with bind-address=*.
MySQL has an internal firewall of users/IPs. Even if you can connect locally, you might not have permission remotely:
Try this as root user on the MySQL server (locally first!)
GRANT ALL ON <db>.* TO '<user>'#'<remoteIP>' IDENTIFIED BY '<password>';
Where
<db> is the name of the DB
<user> is name under which you connect
<remoteIP> is your external office IP FROM which you are trying to connect
<password> should be self-explanatory!
This will explain the options better

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.

Can't connect to localhost MySQL database through command line?

Weird issue. Can't connect to localhost MySQL database from command line, but I can through MySQL program, Sequel Pro. Any ideas why? I entered the same user/password, but I'm getting a access denied error for root#localhost
Extra question: can you run MySQL commands within Sequel Pro? I'm pretty new to MySQL, but I'm just trying to change a simple column definition.
EDIT: reset password from within Sequel Pro query for root, and was able to get it working.
MySQL has different accesses. You can allow a MySQL database to only serve requests from a specific machine, or only from the local machine.
However, note that MySQL differentiates login from "localhost" and from "127.0.0.1".
Try allowing both localhost, 127.0.0.1 and "%" to the account.

remote mysql access showing different database list

I found a weird problem that when I connect to my database which locates at another server, the output of show databases; was different with that when I did local.
My database was running MySQL at IP 10.200.0.11, I connect with mysql -u username -p -h 10.200.0.11
I did some search, seems no people reported this problem? Did my mysql client cached something? I tried another client machine, and it works good through.
Any thoughts? Thanks in advance.