I'm running a VPS to host a Minecraft (video game) server.
For some of the data that the server collects from players, it is more efficient sometimes for it to store user information in a database in order to take a load off of the server.
I have successfully created a MySQL database called "minecraft" in Ubuntu 13.04 terminal.
Here's an image of everything I typed to create the database.
A Minecraft Bukkit server plugin that I am using to test the connection, LogBlock, cannot connect to the server. I have put in the details as follows:
mysql:
user: root
port: 3306
password: -mypassword-
host: localhost
database: minecraft
The Minecraft server simply returns that there is no database connected.
The MySQL server does not seem to be active at all. I have it running, but cannot connect to it through SQuirreL SQL either. Can anyone give me some advice on how I can actually test the database or what I might be doing wrong?
You should consider using 127.0.0.1 or your IP address for the VPS and try again.
Make sure the database can actually establish a connection through the port, just do a quick check here to see if the port is open: http://ping.eu/port-chk/
To check your mysql status on Ubuntu:
status mysql
or this way
pgrep -l mysqld
Hopefully this should help, if you still can't get anywhere then let me know Josias and I can provide further assistance
Setting up a MySQL server for the first time can be tricky. But once you get the hang of things it starts to get real easy. Heres a great place to get started with MySQL on you're ubuntu server: https://help.ubuntu.com/12.04/serverguide/mysql.html
Related
I have been helping troubleshoot a process on an old UBUNTU 16 server. We cannot migrate a site to a new server until we understand how it works as we need to recreate and troubleshoot.
Basically its a python3 script that connects to a MYSQL database and reads some data, and updates data under a certain condition. It is basically linked to ZOHO hence the need for this programming language.
The error has been diagonsed as a mysql connection error. Error 111 connection refused. The database is localhost
I have 100% verified the access for the username, password and database visibiity and that port 3306 is open. I can login using a MYSQL command on the CLU and show the database and its tables.
The connector is 100% pulling in the correct variables from the config.py as I have added a print(HOST, DBASE, USER, PASSWORD) just before the connector and verified they are correct.
I have also tried 127.0.0.1 instead of localhost. I have also (dont shoot me) put in the root username and password to remove any permissions issues
I am wondering if its possible to expand on the mysql error in python so I can get a very clear message as to WHAT part is causing an issue. Is there any command in MYSQL that could have been issued to specifically block python.
I have disabled UFW just in case, made no difference, and the general logs for MYSQL dont appear to contain anything useful
Exact error:
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '127.0.0.1:3306' (111 Connection refused)
Note: The server is Ubuntu 16, running MYSQL 5.7.26-0ubuntu0.16.04.1 with localhost access only. Python is 2.7.12
As noted this is an old server, that I want to scrap ASAP but until I can prove that the zoho connector is fixable, we cant proceed as its a blocker.
As you can see in theexample below.
the port is separate from the host
import mysql.connector
cnx = mysql.connector.connect(
host='localhost',
database='import_test',
user='testuser',
password='password***',
port=3306
)
Turns out to be the most basic of all issues. On the old server we cloned from, everyting was open, zero lockdown including MYSQL listening to the world. On the new server, mysql had skip-networking was enabled.
Whereas the web instances were happily connecting directly to the socket, mysql was not activly listening on port 3306. I had changed my.cnf to enable networking but a different issue was stopping those changes taking place.
Once I had mysql working on port 3306 and I could see it listening, python now connected ok so some of the answers were correct. MYSQL was 'not working;' in a global sense.. HOWEVER this is a step backwards in terms of security. I did not want MYSQL open to the world
So I modified the code to use the unix socket of /var/run/mysqld/mysqld.sock, renenabled skip-networking and voila.. all is now fine with python, port 3306 is shutdown again and I have my first trial by fire of python complete
My config file defines DATABASE as local host, USER and PASSWORD but now has SOCKET as /var/run/mysqld/mysqld.sock and my code is
import mysql.connector
from models import ExportRecord
from config import HOST, USER, PASSWORD, DATABASE, SOCKET
def connect():
return mysql.connector.connect(host=HOST, user=USER, passwd=PASSWORD, database=DATABASE, unix_socket=SOCKET)
I have a project running on Docker and I'm able to connect to the database through the terminal:
mysql -h localhost -P 33060 --protocol=tcp -u 'notmyrealusername' -p
This works fine and I'm able to show the tables from the database.
However, when trying to connect via SequelPro, I get the following error:
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).
MySQL said: Protocol mismatch; server version = 11, client version = 10
Note that the project is running on MySQL 5.7.34 and the version on my computer is 8.0.23.
OS: Mac OS Catalina
What I have tried:
From this thread, I have tried also with the port of 2200 and, well, SequelPro won't let me use 127.0.0.1. So, I couldn't try the second one.
I have also granted all privileges to both 'notmyrealusername'#'127.0.0.1' and 'notmyrealusername'#'localhost', but that didn't seem to fix it either.
Replying to Philippe's questions:
Yes, If I try mysql -h 127.0.0.1, then I get the same error:
ERROR 2007 (HY000): Protocol mismatch; server version = 11, client
version = 10
Question:
Does anyone know either how to connect to 'localhost' and not '127.0.0.1' on SequelPro or why I can't seem to connect to this database on SequelPro, when, with the same data, I can easily connect via terminal?
Thanks in advance for all of the help/suggestions you can provide!
Thanks!
I have finally found the solution. For anyone wondering, the key here is that I am using Docker. In this case, as outlined in this forum post, we need to:
Use the IP address of the machine where the database is running (the
real one, not localhost) as host address.
How?
Go to your terminal and use the command ifconfig . You'll get a bunch of data, but what you're looking for is the local network IP address. This usually looks like either 192.x.x.x or 10.x.x.x.
Then, in Sequel Pro or whatever GUI you are using, use this address (192....) instead of localhost.
I hope this helps someone and saves you time :)
Happy coding!
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
I am trying to save myself some time and eye strain by connecting my to MySQL on my VM (Ubuntu 14.04)
I have a bridged connection set up, and I test my web applications on my windows by simply navigating to http://ip_of_vm/application/index.php, so I know that they are communicating. However, when I tried setting up the connection in MySQL Workbench, I come to a screeching halt. Here are my connection parameters:
Hostname: ip_of_vm
Port: 3306 (Default)
Username: tim -> Which is a user created on my VM using: CREATE USER 'tim'#'%' in MySQL
Password: **** -> No I'm not going to paste my password here.
Default Schema: test_database
But when I press test connection I get this error:
Failed to connect to MySQL at ip_of_vm with user tim.
Can't connect to MySQL server on ip_of_vm (10061)
I've tried searching for that error code and making some adjustments based on what I've found, but I'm still having no luck.
Any suggestions would be greatly appreciated.
I am trying to connect Coldfusion 9 to a MYSQL Database that was installed by MAMP (free not Pro) with the following parameters:
CF Data Source Name: MyDatasource
Database: MyDatabase
Server: localhost
Port: 8889
Username: root
Password: root
In the coldfusion Administrator I can successfully connect to this database. However, when I try to display a .cfm page that has a connection to that datasource, this error is thrown:
Error Executing Database Query.
Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Any ideas??
Any help would be immensely appreciated!!
edit
this is what MAMP wants me to use and it did create a successful connection in CF Admin.
In the CF admin, if you click "Verify" it shows a successful connection? Usually MySQL databases are on port 3306 not 8889. Are you sure you have the correct settings?
So, after searching and trying to figure out what is going on, I decided to check my Application.cfm file, and sure enough, I have global connection strings for all of my queries. One of those strings was the DB password, which was not set to "root".. Thank you for your help and I apologize for the stupid question..