Today I will discuss about the one issue related to MySQL (or you can say Mariadb). As we know that mariadb is the default database when we install MySQL in the Linux server. So when we execute the command “
yum install mysql“, it will install mariadb database. You can check the below snapshot for your reference.
So by the above method, I have installed mariadb in the test server.
When I tried to enable the maridb database or to start the mariadb database, it was started throwing the below error:
From the error message, we can understand that mariadb.service or simply mariadb unit is not present in the server. But how this can be possible, as when installing the mariadb database, it shown that mariadb is successfully installed in the server. You will see the mariadb version and almost all the files related to mariadb database and its configuration. But you will see that mysql demon files will not be present. Check the below snapshots.
After checking the issue in detail, I came to know that for running mariadb database there should be 3 packages (mariadb, mariadb-lib and mariadb-server) installed in the server. But when I checked the installed package for mariadb, it was only showing 2 packages.
Now we can say that this is the reason why mariadb is not getting started, showing the error “Unit not found” and ” Access Denied” and not having files related to mysql demon. For running the mariadb database in the server, there should be 3 mariadb packages installed in the server.
We need to install mariadb-server to resolve the issue. Execute the below command to install mariadb-server.
yum install mariadb-server
The above command will install mariadb-server.
After successful installation, you will see that files related to MySQL demon will be present and the mariadb-server will be installed in the server.
Now we can easily start and enable mariadb database in the server.
From this post we learn that mariadb is the default database, so if we execute yum install mysql, it will install mariadb in the server, but it will not install all the required packages in the server. To install the 3rd package(which is very important to start the mariadb service) i.e. mariadb-server package, we have to manually install it (by executing the command “yum install mariadb-server”).
EXTRA POINT: We can also avoid these lengthy steps and directly installed mariadb database by executing the below command:
yum install maridb-server
The above command will install mariadb server and its dependencies (that is required for mariadb database server). To install MySQL database in the server, execute “
yum install mysql-server“.
IMPORTANT: If we install mariadb by executing “
yum install mysql” and then if we execute yum install mariadb-server, then other dependencies will be installed which will be different from the dependencies when we directly execute “
yum install mariadb-server“.
Bonus: What is mysql.sock and how it is created?
mysql.sock file is a special pseudo file used for data transmission. The data is transmitted by reading and writing and not by storing the data. The socket file is created when the service is started and removed when the service is terminated. The location of the file is defined in /etc/my.cnf and it is present in the location “/var/lib/mysql/“.
If you have any question, feel free to comment in the below comment section. Thank you.
My name is Shashank Shekhar. I am a DevOps Engineer, currently working in one of the best companies in India. I am having around 5 years of experience in Linux Server Administration and DevOps tools.
I love to work in Linux environment & love learning new things.
Powered by Facebook Comments