Enjoy Slackware 15.0!

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 revision Both sides next revision
howtos:databases:install_mysql_on_slackware [2012/09/26 02:35 (UTC)]
mfillpot moved from the general howtos namespace
howtos:databases:install_mysql_on_slackware [2013/02/11 16:49 (UTC)]
wisedraco [Configure MySQL]
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>
  
-1Create the needed database(s) and set their permissions properlyAs rootrun:+== 3Enable networking if needed == 
 +Networking is disabled by default to improve securityIf you want to allow 
 +network connectionscomment out this line in ''/etc/rc.d/rc.mysqld'' 
 +<file sh rc.mysqld> 
 +#SKIP="--skip-networking" 
 +</file>
  
-     mysql_install_db --user=mysql+== 4) Start mysqld == 
 +<code> 
 +root@darkstar# /etc/rc.d/rc.mysqld start 
 +</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 safe choice.   +<note> 
 +Now you have a choice : Manual Install or Automatic 
 +</note>
  
-2Enable execution of rc script to start MySQL automatically on boot:+== AUTOMATIC == 
 +== 56) 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>//
  
-     chmod 755 /etc/rc.d/rc.mysqld+== MANUAL ==
  
-3Enable networking if needed+== 5Set a password for MySQL's root password == 
 +<code> 
 +root@darkstar# mysqladmin -u root password 'new-password-here' 
 +</code>
  
-Networking is disabled by default to improve security. If you want to allow network connectionscomment out this line in /etc/rc.d/rc.mysql +If you enabled networkingyou should also run this command: 
-     #SKIP="--skip-networking" +<code> 
-  +root@darkstarmysqladmin -u root -h 'your-hostname' password 'new-password' 
-4) Start mysqld:+</code>
  
-     /etc/rc.d/rc.mysqld start+<note tip> 
 +Check the ''mysql_install_db'' results, these commands are printed, you can 
 +copy/paste themThe hostname will already be replaced by yours. 
 +</note>
  
-//NOW YOU HAVE A CHOICE MANUAL INSTALL OR AUTOMATIC//+== 6) Connect to your MySQL server == 
 +<code> 
 +user@darkstar$ mysql -u root -p 
 +</code>
  
-AUTOMATIC: 
  
-5) 6) 7) Run the following, answer the questions:+== 7) For security reasons you should delete the anonymous user == 
 +For the localhost server:
  
-     /usr/bin/mysql_secure_installation +<code> 
-          Initial root password is "" sojust hit <ENTER>+mysql> use mysql 
 +mysql> SELECT userhost FROM user; 
 +mysql> DELETE FROM user WHERE host='localhost' AND user=''; 
 +</code>
  
-MANUAL:+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>
  
-5) Set a password for MySQL's root password:+== Finish set configfile == 
 +  * Go to ''/etc/mysql'' folder, and choose config, who you prefer ( for simple variants without heavy mysql load,if you have 2+ Gb RAM, i recommend my-large.cnf) and copy it to \ as ''/etc/my.cnf''
 +  * Edit ''/etc/my.cnf'' adding these lines after [mysqld]: 
 +<code> 
 +[mysqld] 
 +collation-server = utf8_unicode_ci 
 +init-connect='SET NAMES utf8' 
 +character-set-server = utf8 
 +</code> 
 +This gives you full utf8 on your mysql server, after restart it.
  
-     mysqladmin -u root password 'new-password-here' 
  
 +===== Troubleshooting =====
 +  * 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:
 +<code>
 +root@darkstar# /usr/bin/mysqld_safe --console
 +</code>
  
-6) You can connect to your MySQL server with+  * 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)
-     mysql -u root -p+<file sql mysql_new.cnf> 
 +UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; 
 +FLUSH PRIVILEGES; 
 +</file>
  
- +Save this file (any name would do) and start the server with the --init-file 
-7) For security reasons you should delete an empty user for localhost server +argument: 
- +<code> 
-     mysql> use mysql +root@darkstar# /usr/bin/mysqld_safe --defaults-file="new_cnf_file.cnf" 
-     mysql> SELECT user, host FROM user; +</code>
-     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 ====== ====== Sources ======
Line 79: Line 126:
 <!-- 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}} 

In Other Languages
QR Code
QR Code howtos:databases:install_mysql_on_slackware (generated for current page)