[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

This is an old revision of the document!


Install MySQL On Slackware

INSTALL MySQL

Install MySQL from the official Slackware discs or using [slackpkg].

CONFIGURE MySQL

1) Create the needed database(s) and set their permissions properly. As root, run:

   mysql_install_db --user=mysql

User specified by –user will own database files, so it's important to set right user here, otherwise MySQL won't be able to write to database. By default MySQL in Slackware runs as user “mysql”, so it's safe choice.

2) Enable execution of rc script to start MySQL automatically on boot:

   chmod 755 /etc/rc.d/rc.mysqld

3) Enable networking if needed

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

   #SKIP="--skip-networking"

4) Start mysqld:

   /etc/rc.d/rc.mysqld start

NOW YOU HAVE A CHOICE - MANUAL INSTALL OR AUTOMATIC

AUTOMATIC:

5) 6) 7) Run the following, answer the questions:

   /usr/bin/mysql_secure_installation
        Initial root password is "" so, just hit <ENTER>

MANUAL:

5) Set a password for MySQL's root password:

   mysqladmin -u root password 'new-password-here'

6) You can connect to your MySQL server with:

   mysql -u root -p

7) For security reasons you should delete an empty user for localhost server

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

1) Server start errors can be seen in the error log that is located by default at /usr/lib/mysql/<hostname>.err. Another option is to run the server directly and direct the output to the console:

/usr/bin/mysqld_safe --console

2 Resetting the root password can be done by creating a new cnf file and add the following lines (please change the password in this example):

UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
FLUSH PRIVILEGES;

Save this file (any name would do) and start the server with the –init-file argument:

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

Sources

 howtos:databases:install_mysql_on_slackware ()