![]() Make sure the settings point to the correct directories so that MySQL can actually find the required files. The parameters in the example above are in their default values, and in most cases, your configuration would look the same. The lines here to pay close attention to are ‘socket’, ‘datadir’ and ‘bind-address’. With CentOS and other Red Hats, the primary configuration file is stored at the slightly different location, open it for inspection with sudo vi /etc/my.cnf # localhost which is more compatible and is not less secure. # Instead of skip-networking the default is now to listen only on sudo nano /etc/mysql/my.cnfīy scrolling down past and settings you’ll find something like the example here. You can open the global configuration file with first of the following two commands below, and the user-specific with the latter by replacing the with a database username. ![]() It is commonly advised to have separate usernames for different web applications, so check at least those relevant to your page loading issues. Check if any user level overrides have been set. It’s also possible to have user-specific settings stored at /home//.my.cnf, which would override the global configurations. On Debian and Ubuntu servers the configuration file for MySQL is usually saved at /etc/mysql/. ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111) When MySQL is running but your website still doesn’t load as it should, or if 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. You can test the database connection from your web server with the command underneath using the correct username for your installation. If you have your database set up on a separate server from your web host, make sure the two servers can reach each other. ERROR 1045 (28000): Access denied for user (using password: YES) 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. If instead, you get an error like this example below you probably mistyped the password for root user. If you are greeted with “Welcome to the MySQL/MariaDB monitor” the connection was successful and the database service is running. Should the database service restart without encountering errors, you can try to connect to it using the command below. If your service status says something other than ‘running’, try to restart the process using the same service command as before but with ‘restart’ instead of ‘status’. Ubuntu condenses the same information to a one-liner like an example output underneath. In green ‘active (running)’ means the service should be running normally if instead, it says ‘active (exited)’ or ‘inactive (dead)’ the process has been stopped or killed. ![]() ![]() The printout is rather verbose, but the important part is usually coloured to stand out better. └─2609 /usr/libexec/mysqld -basedir=/usr -datadir=/var/lib/mysql. ├─2451 /bin/sh /usr/bin/mysqld_safe -basedir=/usr Loaded: loaded (/usr/lib/systemd/system/rvice enabled)Īctive: active (running) since Wed 11:53:38 EEST 3h 23min ago 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 different service name. sudo service mysql statusĬentOS and other Red Hat variants use MySQL as well, but it is named MariaDB instead, so use this command instead. Check your MySQL state, on Ubuntu and Debian systems this can be done with the following command. If your website cannot connect to your database, it is possible the service is simply not listening. Try UpCloud for free! Deploy a server in just 45 seconds Check that the service is running But what to do when suddenly your dynamic content doesn’t load, or when returning to your website you are greeted by a nearly empty white page with message “Error establishing a database connection.” This guide is aimed at helping with troubleshooting MySQL databases on cloud servers, and by following the steps listed here you’ll hopefully be able to restore your database functionality. A big part of the content on the Internet is stored on databases for which MySQL is a popular choice. ![]()
0 Comments
Leave a Reply. |