Skip to content

MySQL Connection Problems

Olek edited this page Feb 4, 2020 · 8 revisions

There could not be established a connection to the MySQL server. This can have many reasons.

  • Your MySQL server could be down. Start it with /etc/init.d/mysqld restart on Linux or net start mysql on Windows.

Local MySQL Server

  • Try to use 127.0.0.1 or the domain instead of localhost.

  • Look which port your MySQL server is listening for: Open MySQL config (explained below) and watch for:

    [mysqld]
    
    # The TCP/IP Port the MySQL Server will listen on
    port=3306

Remote MySQL server

  • Check whether you spelled the ip right. Don’t use your your ip, when it’s not static, better use the domain.

  • Check whether the server where your MySQl server is hosted is accessible at all: ping <ip>

  • The MySQL server has to accept remote connections. Many hosted MySQL servers refuse that. Ask your hoster if they could enable it for you. When you’ve root access to your MySQL server, you good luck, you can set it yourself. Open the MySQL config, it’s normally located at /etc/mysql/my.cnf on Linux or C:\Programme\MySQL\MySQL Server 5.5\my.ini in Windows, and make sure that skip-networking is deleted or outcommented and set bind-address to the ip (or better domain) of your Minecraft server.

Access denied for user '<user>'@'<host>' (using password: NO)

  • Make sure you put the password in singlequotes, like 'pw'. If your MySQL user doesn’t have a password (really not recommended!) use an empty string: ''.

  • If it keeps telling password: NO but you’ve entered one, you are trying to use a username that doesn’t exist.

Access denied for user '<user>'@'<host>' (using password: YES)

  • Check if you spelled the password right. (single quotes again!)

  • The user might not have sufficient rights on the database. Grant all privileges to the user with this query: GRANT ALL PRIVILEGES ON <database> TO '<user>'@'localhost'; The quotes around user and host are necessary. If you’ve a remote server, use '%' instead of 'localhost'

Creating Tables Manually

Execute the following sql queries to create manually. Replace main with the actual name the table you specified in world config.

CREATE TABLE `lb-players` (playerid SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT, UUID varchar(36) NOT NULL, playername varchar(32) NOT NULL DEFAULT '-', PRIMARY KEY (playerid), UNIQUE (playername));
CREATE TABLE `lb-chat` (id INT UNSIGNED NOT NULL AUTO_INCREMENT, date DATETIME NOT NULL, playerid SMALLINT UNSIGNED NOT NULL, message VARCHAR(255) NOT NULL, PRIMARY KEY (id), KEY playerid (playerid), FULLTEXT message (message)) ENGINE=MyISAM;
CREATE TABLE `lb-main` (id INT UNSIGNED NOT NULL AUTO_INCREMENT, date DATETIME NOT NULL, playerid SMALLINT UNSIGNED NOT NULL, replaced TINYINT UNSIGNED NOT NULL, type TINYINT UNSIGNED NOT NULL, data TINYINT UNSIGNED NOT NULL, x SMALLINT NOT NULL, y TINYINT UNSIGNED NOT NULL, z SMALLINT NOT NULL, PRIMARY KEY (id), KEY coords (x, z, y), KEY date (date), KEY playerid (playerid));
CREATE TABLE `lb-main-sign` (id INT UNSIGNED NOT NULL, signtext VARCHAR(255) NOT NULL, PRIMARY KEY (id));
CREATE TABLE `lb-main-chest` (id INT UNSIGNED NOT NULL, itemtype SMALLINT UNSIGNED NOT NULL, itemamount SMALLINT NOT NULL, itemdata TINYINT UNSIGNED NOT NULL, PRIMARY KEY (id));
CREATE TABLE `lb-main-kills` (id INT UNSIGNED NOT NULL AUTO_INCREMENT, date DATETIME NOT NULL, killer SMALLINT UNSIGNED, victim SMALLINT UNSIGNED NOT NULL, weapon SMALLINT UNSIGNED NOT NULL, PRIMARY KEY (id));