Set Up and Configuring MySQL in Slackware Linux

Home / Set Up and Configuring MySQL in Slackware Linux

Set Up and Configuring MySQL in Slackware Linux

December 3, 2015 | Article | No Comments

MySQL is indeed one of popular database management system used worldwide. Not to mention it is open source and free to use. Practically, MySQL is often used together with PHP server-side scripting language, apache web server, and linux as the server platform.

For you who come from another distribution such as Ubuntu, Mint, Fedora, or even from another Operating System such as Windows or Mac, maybe you will be surprised. If you have done full slackware installation, you actually have install MySQL. MySQL Is shipped to default Slackware installation, but wait! We have to configure it first.

This article will discussed about how to properly configure your MySQL DBMS from zero to be available.

In this article, I am using:

  1. Slackware64-bit version 14.0 with multilib enabled

First, we need to check wether mysql user and mysql group already exist in the system. If you installed mysql during installation then you must have it

$ less /etc/passwd | grep mysql
mysql:x:27:27:MySQ

If you are prompted with something like that, then MySQL is already installed. If not, grab your installation DVD and search for the MySQL.

Now, we must create the initial database and set permission. Do this as root.

mysql_install_db --user=mysql

User specified by –user will own database files. Thus, it is important to set the user with the right one. If you are not do this, MySQL won’t be able to write to database. In Slackware, MySQL runs as user mysql by default.

Networking is disabled by default for security issue. If you want to allow network connections, you should comment out this line in /etc/rc.d/rc.mysqld

#SKIP="--skip-networking"

To start mysql, we must run the daemon. To run it, we simply execute a script on /etc/rc.d/ directory named rc.mysqld. Of course, you must check whether the file is executable or not. Once executed, you will have MySQL running:

/etc/rc.d/rc.mysqld start

Congratulation! MySQL has been successfully ran! Up to this point the MySQL is up but won’t behave as you need until you have configure it.

The Fresh installation of MySQL has a blank password for root of DB. Well, you know what it means, don’t you? A blank-password for root means your database is very vulnerable so we must give it password. To do so, do this:

mysqladmin -u root password 'your-new-password'

and do this also (for network access login)

mysqladmin -u root -h 'your-hostname' password 'your-new-password'

Try login using user root with your specified password.

Next thing to do is removing anonymous user. Anonymous user is by default a user which can access database with no authentication (for testing purpose). Better remove it as soon as possible. Run these command from mysql terminal.

mysql> use mysql
mysql> SELECT user, host FROM user;
mysql> DELETE FROM user WHERE host='localhost' AND user='';

And let me congratulate you again! You have properly configure MySQL for first-time use 🙂

Things to know

Default log is located at /var/lib/mysql/<hostname>.err.

You can also reset the password by save these lines as xath_user_modify.cnf:

UPDATE Mysql.USER SET Password=PASSWORD('Your new password') WHERE USER='root';
FLUSH PRIVILEGES;

Then load the saved file using:

/usr/bin/mysqld_safe --defaults-file="xath_user_modify.cnf"

 

, ,

About Author

about author

xathrya

A man who is obsessed to low level technology.

Leave a Reply

Your email address will not be published. Required fields are marked *

Social media & sharing icons powered by UltimatelySocial