[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

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
howtos:databases:install_mysql_on_slackware [2012/09/26 02:35 (UTC)] – moved from the general howtos namespace mfillpothowtos:databases:install_mysql_on_slackware [2013/01/06 04:05 (UTC)] – added REVIEWED comment mfillpot
Line 1: Line 1:
 +<!-- Reviewed 2012-01-05 mfillpot -->
 <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). --> <!-- Add your text below. We strongly advise to start with a Headline (see button bar above). -->
 ====== Install MySQL On Slackware ====== ====== Install MySQL On Slackware ======
  
-== INSTALL MySQL ==+===== Install MySQL ===== 
 +Install MySQL from the official Slackware discs or using 
 +[[slackware:slackpkg|slackpkg]].
  
-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: 
 +<code> 
 +root@darkstar# mysql_install_db --user=mysql 
 +</code>
  
 +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 the safe choice.
  
-== CONFIGURE MySQL ==+== 2) Enable execution of rc script to start MySQL automatically on boot == 
 +//This is optional.// 
 +<code> 
 +root@darkstar# chmod 755 /etc/rc.d/rc.mysqld 
 +</code>
  
-1) Create the needed database(s) and set their permissions properly. As root, run: +=3) Enable networking if needed == 
- +Networking is disabled by default to improve security. If you want to allow 
-     mysql_install_db --user=mysql +network connections, comment out this line in ''/etc/rc.d/rc.mysqld'' 
- +<file> 
-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.    +#SKIP="--skip-networking" 
- +</file>
-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: +== 4) Start mysqld == 
- +<code> 
-     /etc/rc.d/rc.mysqld start+root@darkstar# /etc/rc.d/rc.mysqld start 
 +</code>
  
-//NOW YOU HAVE A CHOICE - MANUAL INSTALL OR AUTOMATIC//+<note> 
 +Now you have a choice : Manual Install or Automatic 
 +</note>
  
-AUTOMATIC:+== AUTOMATIC == 
 +== 5) 6) 7) Run the following, answer the questions == 
 +<code> 
 +root@darkstar# /usr/bin/mysql_secure_installation 
 +</code> 
 +// Initial root password is "" so, just hit <key>ENTER</key>//
  
-5) 6) 7) Run the following, answer the questions:+== MANUAL ==
  
-     /usr/bin/mysql_secure_installation +== 5) Set a password for MySQL's root password == 
-          Initial root password is "" so, just hit <ENTER>+<code> 
 +root@darkstar# mysqladmin -u root password 'new-password-here' 
 +</code>
  
-MANUAL:+If you enabled networking, you should also run this command: 
 +<code> 
 +root@darkstar# mysqladmin -u root -h 'your-hostname' password 'new-password' 
 +</code>
  
-5) Set a password for MySQL's root password:+<note tip> 
 +Check the ''mysql_install_db'' results, these commands are printed, you can 
 +copy/paste them. The hostname will already be replaced by yours. 
 +</note>
  
-     mysqladmin -u root password 'new-password-here'+== 6) Connect to your MySQL server == 
 +<code> 
 +user@darkstar$ mysql -u root -
 +</code>
  
  
-6You can connect to your MySQL server with: +== 7For security reasons you should delete the anonymous user == 
-     mysql -u root -p+For the localhost server:
  
 +<code>
 +mysql> use mysql
 +mysql> SELECT user, host FROM user;
 +mysql> DELETE FROM user WHERE host='localhost' AND user='';
 +</code>
  
-7) For security reasons you should delete an empty user for localhost server+If you enabled networking, you should run this command instead: 
 +<code> 
 +mysql> use mysql 
 +mysql> SELECT user, host FROM user; 
 +mysql> DELETE FROM user WHERE user=''; 
 +</code>
  
-     mysql> use mysql +===== Troubleshooting ===== 
-     mysqlSELECT user, host FROM user; +  * Server start errors can be seen in the error log that is located by default at ''/var/lib/mysql/<hostname>.err''. Another option is to run the server directly and direct the output to the console (use <key>C-\</key> to stop the server). Run: 
-     mysqlDELETE FROM user WHERE host='localhost' AND user='';+<code
 +root@darkstar# /usr/bin/mysqld_safe --console 
 +</code>
  
-== TROUBLESHOOTING == +  * 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): 
-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: +<file> 
-   +UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; 
-  /usr/bin/mysqld_safe --console +FLUSH PRIVILEGES; 
-   +</file>
-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: +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" +<code> 
-  +root@darkstar# /usr/bin/mysqld_safe --defaults-file="new_cnf_file.cnf" 
 +</code>
  
 ====== Sources ====== ====== Sources ======
Line 79: Line 114:
 <!-- Please do not modify anything below, except adding new tags.--> <!-- Please do not modify anything below, except adding new tags.-->
 <!-- You must remove the tag-word "template" below before saving your new page --> <!-- You must remove the tag-word "template" below before saving your new page -->
-{{tag>howtos software mysq author_arfon}}+{{tag>howtos software mysql database author_arfon needs_content}}
 howtos:databases:install_mysql_on_slackware ()