Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the acf domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php on line 6131

Deprecated: Creation of dynamic property ACF::$fields is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields.php on line 138

Deprecated: Creation of dynamic property acf_loop::$loops is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/loop.php on line 28

Deprecated: Creation of dynamic property ACF::$loop is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/loop.php on line 269

Deprecated: Creation of dynamic property ACF::$revisions is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/revisions.php on line 397

Deprecated: Creation of dynamic property acf_validation::$errors is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/validation.php on line 28

Deprecated: Creation of dynamic property ACF::$validation is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/validation.php on line 214

Deprecated: Creation of dynamic property acf_form_customizer::$preview_values is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-customizer.php on line 28

Deprecated: Creation of dynamic property acf_form_customizer::$preview_fields is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-customizer.php on line 29

Deprecated: Creation of dynamic property acf_form_customizer::$preview_errors is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-customizer.php on line 30

Deprecated: Creation of dynamic property ACF::$form_front is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-front.php on line 598

Deprecated: Creation of dynamic property acf_form_widget::$preview_values is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-widget.php on line 34

Deprecated: Creation of dynamic property acf_form_widget::$preview_reference is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-widget.php on line 35

Deprecated: Creation of dynamic property acf_form_widget::$preview_errors is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/forms/form-widget.php on line 36

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the all-in-one-wp-migration domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php on line 6131

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/wp_plugin/wp_plugin.php on line 23

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 54

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 1539

Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 828

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the rocket domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php on line 6131

Deprecated: Creation of dynamic property acf_field_oembed::$width is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-oembed.php on line 31

Deprecated: Creation of dynamic property acf_field_oembed::$height is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-oembed.php on line 32

Deprecated: Creation of dynamic property acf_field_google_map::$default_values is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-google-map.php on line 33

Deprecated: Creation of dynamic property acf_field__group::$have_rows is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/includes/fields/class-acf-field-group.php on line 31

Deprecated: Creation of dynamic property acf_field_clone::$cloning is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-clone.php on line 34

Deprecated: Creation of dynamic property acf_field_clone::$have_rows is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-pro/pro/fields/class-acf-field-clone.php on line 35

Deprecated: Creation of dynamic property jh_acf_field_table::$settings is deprecated in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-content/plugins/advanced-custom-fields-table-field/class-jh-acf-field-table.php on line 23

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/functions.php:6131) in /var/www/vhosts/studiogo.tech/httpdocs/upcloudold/wp-includes/rest-api/class-wp-rest-server.php on line 1902
{"id":24480,"date":"2015-08-07T12:33:14","date_gmt":"2015-08-07T09:33:14","guid":{"rendered":"https:\/\/upcloud.com\/community\/tutorials\/fix-common-problems-mysql-databases"},"modified":"2015-08-07T12:33:14","modified_gmt":"2015-08-07T09:33:14","slug":"fix-common-problems-mysql-databases","status":"publish","type":"tutorial","link":"https:\/\/studiogo.tech\/upcloudold\/tutorial\/fix-common-problems-mysql-databases\/","title":{"rendered":"How to fix common problems with MySQL databases"},"content":{"rendered":"\n

A big part of the content on the Internet is stored on databases for which MySQL is a popular choice. But what to do when suddenly your dynamic content doesn\u2019t load, or when returning to your website you are greeted by a nearly empty white page with the message \u201cError establishing a database connection.\u201d This guide is aimed at helping with troubleshooting MySQL databases on cloud servers<\/a>, and by following the steps listed here you\u2019ll hopefully be able to restore your database functionality.<\/p>\n\n\n\n

\n
Try UpCloud for free!<\/a><\/div>\n<\/div>\n\n\n\n

Check that the service is running<\/h2>\n\n\n\n

If your website cannot connect to your database, it is possible the service is simply not listening. Check your MySQL state, on Ubuntu and Debian systems this can be done with the following command.<\/p>\n\n\n\n

sudo service mysql status<\/pre>\n\n\n\n

CentOS and other Red Hat variants use MySQL as well, but it is named MariaDB instead, so use this command instead.<\/p>\n\n\n\n

sudo service mariadb status<\/pre>\n\n\n\n

The output from the status check on CentOS and Debian will show something along the lines of this example from CentOS below, Debian output would be nearly identical with the exception of a different service name.<\/p>\n\n\n\n

mariadb.service - MariaDB database server\n    Loaded: loaded (\/usr\/lib\/systemd\/system\/mariadb.service; enabled)\n    Active: active (running)<\/span> since Wed 2015-08-05 11:53:38 EEST; 3h 23min ago\n  Main PID: 2451 (mysqld_safe)\n    CGroup: \/system.slice\/mariadb.service\n            \u251c\u25002451 \/bin\/sh \/usr\/bin\/mysqld_safe --basedir=\/usr\n            \u2514\u25002609 \/usr\/libexec\/mysqld --basedir=\/usr --datadir=\/var\/lib\/mysql...<\/pre>\n\n\n\n

The printout is rather verbose, but the important part is usually coloured to stand out better. In green \u2018active (running)\u2019 means the service should be running normally if instead, it says \u2018active (exited)\u2019 or \u2018inactive (dead)\u2019 the process has been stopped or killed.<\/p>\n\n\n\n

Ubuntu condenses the same information to a one-liner like an example output underneath.<\/p>\n\n\n\n

mysql start\/running, process 5897<\/pre>\n\n\n\n

If your service status says something other than \u2018running\u2019, try to restart the process using the same service command as before but with \u2018restart\u2019 instead of \u2018status\u2019.<\/p>\n\n\n\n

sudo service mysql restart\n\nsudo service mariadb restart<\/pre>\n\n\n\n

Should the database service restart without encountering errors, you can try to connect to it using the command below. Enter the root password when prompted.<\/p>\n\n\n\n

mysql -u root -p<\/pre>\n\n\n\n

If you are greeted with \u201cWelcome to the MySQL\/MariaDB monitor\u201d the connection was successful and the database service is running. If instead, you get an error like this example below you probably mistyped the password for the root user. Try again, or if you are not sure about the root password, log in with another user account you have access to by just replacing root with the other username.<\/p>\n\n\n\n

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)<\/pre>\n\n\n\n

If you have your database set up on a separate server from your web host, make sure the two servers can reach each other. You can test the database connection from your web server with the command underneath using the correct username for your installation.<\/p>\n\n\n\n

mysql -u <user name> -p -h <database server private IP><\/pre>\n\n\n\n

Check the configuration<\/h2>\n\n\n\n

When MySQL is running but your website still doesn\u2019t load as it should, or when attempting to connect to your database manually you get an error message like the one below, you should take a look at the service configuration.<\/p>\n\n\n\n

ERROR 2002: Can't connect to local MySQL server through socket '\/tmp\/mysql.sock' (111)<\/pre>\n\n\n\n

On Debian and Ubuntu servers the configuration file for MySQL is usually saved at \/etc\/mysql\/. It\u2019s also possible to have user-specific settings stored at \/home\/<user>\/.my.cnf, which would override the global configurations. Check if any user level overrides have been set. It is commonly advised to have separate usernames for different web applications, so check at least those relevant to your page loading issues. You can open the global configuration file with the first of the following two commands below, and the user-specific with the latter by replacing the <user> with a database username.<\/p>\n\n\n\n

sudo nano \/etc\/mysql\/my.cnf\n\nsudo nano \/home\/<user>\/.my.cnf<\/pre>\n\n\n\n

By scrolling down past [client] and [mysqld_safe] settings you\u2019ll find something like the example here.<\/p>\n\n\n\n

[mysqld]\n#\n# * Basic Settings\n#\nuser            = mysql\npid-file        = \/var\/run\/mysqld\/mysqld.pid\nsocket          = \/var\/run\/mysqld\/mysqld.sock\nport            = 3306\nbasedir         = \/usr\ndatadir         = \/var\/lib\/mysql\ntmpdir          = \/tmp\nlc-messages-dir = \/usr\/share\/mysql\nskip-external-locking\n#\n# Instead of skip-networking the default is now to listen only on\n# localhost which is more compatible and is not less secure.\nbind-address            = 127.0.0.1\n<\/pre>\n\n\n\n

With CentOS and other Red Hats, the primary configuration file is stored at the slightly different location, open it for inspection with<\/p>\n\n\n\n

sudo vi \/etc\/my.cnf<\/pre>\n\n\n\n
[mysqld]\ndatadir=\/var\/lib\/mysql\nsocket=\/var\/lib\/mysql\/mysql.sock<\/pre>\n\n\n\n

The lines here to pay close attention to are \u2018socket\u2019, \u2018datadir\u2019 and \u2018bind-address\u2019. The parameters in the example above are in their default values, and in most cases, your configuration would look the same. Make sure the settings point to the correct directories so that MySQL can actually find the required files. The easiest way to check the \u2018datadir\u2019 is to use this command below<\/p>\n\n\n\n

sudo ls -l \/var\/lib\/mysql\/<\/pre>\n\n\n\n

The output will list all files in that directory, it should contain at least the following plus any databases you have created.<\/p>\n\n\n\n

drwx------ 2 mysql root      4096 Aug  5 12:23 mysql\ndrwx------ 2 mysql mysql     4096 Aug  5 12:29 performance_schema\n<\/pre>\n\n\n\n

If the data directory or socket has been moved and MySQL doesn\u2019t know where they are, fix the configuration file to point to the correct directories. You can search for the folders with the following command.<\/p>\n\n\n\n

sudo find \/ -name performance_schema  && sudo find \/ -name mysql.sock<\/pre>\n\n\n\n

The third parameter you\u2019ll need to check is the bind address, this is only really relevant if your database needs to be accessed remotely. In Debian and Ubuntu installations the bind is by default set to the loopback address, which prevents database calls from outside the localhost. CentOS doesn\u2019t have the same parameter unless manually set. For any setup where your web service is on a different server to the database, this bind address should be set to the server\u2019s own private IP.<\/p>\n\n\n\n

Check the error logs<\/h2>\n\n\n\n

If the configuration seems correct and the service is running, but your website still doesn\u2019t load as it should, try checking the logs for any hints to as what might be the cause.<\/p>\n\n\n\n

Debian and Ubuntu servers store error logs to \/var\/log\/mysql\/error.log. You can read through the logs with \u2018less\u2019, but this might not be very convenient as the log includes more than just critical errors. Instead, search the logs using \u2018grep\u2019.<\/p>\n\n\n\n

sudo grep -i error \/var\/log\/mysql\/error.log<\/pre>\n\n\n\n

Should you not be able to find anything within the most recent logs, check the archived ones as well. To do this, use \u2018zgrep\u2019 with otherwise the same command as regular \u2018grep\u2019<\/p>\n\n\n\n

sudo zgrep -i error \/var\/log\/mysql\/error.log.1.gz<\/pre>\n\n\n\n

Since the database under CentOS is named MariaDB instead of MySQL, the logs are also saved under a different name. You can search the logs with the following command.<\/p>\n\n\n\n

sudo grep -i error \/var\/log\/mariadb\/mariadb.log<\/pre>\n\n\n\n

Debian systems also report MySQL events to \/var\/log\/syslog, to filter out everything else, use \u2018grep\u2019 with two keywords separated by .* to express \u2018and\u2019 like in the command below.<\/p>\n\n\n\n

sudo grep -i -E 'mysql.*error' \/var\/log\/syslog<\/pre>\n\n\n\n

If you are having difficulties finding anything helpful, try different keywords such as \u2018start\u2019 to see when the service was last restarted, or \u2018failed\u2019 to find any less critical problems that might not be reported as errors.<\/p>\n\n\n\n

Ask for help<\/h2>\n\n\n\n

Optimistically by now your database should be up and running again, but in case you\u2019ve encountered a more persistent error, feel free to ask for help. Contact our support team<\/a> and try to explain the problem to the best of your ability, also include the steps you\u2019ve taken with their results while troubleshooting the issue. This will help the team in helping you with the problem.<\/p>\n","protected":false},"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","community-category":[123,124],"class_list":["post-24480","tutorial","type-tutorial","status-publish","hentry","community-category-troubleshooting","community-category-databases"],"acf":[],"_links":{"self":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/tutorial\/24480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/tutorial"}],"about":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/types\/tutorial"}],"replies":[{"embeddable":true,"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/comments?post=24480"}],"wp:attachment":[{"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/media?parent=24480"}],"wp:term":[{"taxonomy":"community-category","embeddable":true,"href":"https:\/\/studiogo.tech\/upcloudold\/wp-json\/wp\/v2\/community-category?post=24480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}