/|\

Welcome to the Slackware Documentation Project

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
howtos:databases:install_mysql_on_slackware [2012/09/29 17:27 (UTC)]
zithro see talk page
howtos:databases:install_mysql_on_slackware [2013/02/12 11:31 (UTC)] (current)
alienbob Layout changes (proper heading/enumeration) and use of correct english in the new UTF8 section.
Line 1: Line 1:
-<!-- Add your text below. We strongly advise to start with a Headline (see button bar above). -->+<!-- Reviewed 2012-01-05 mfillpot --> 
 +<!-- Reviewed 2012-02-12 alienbob -->
 ====== Install MySQL On Slackware ====== ====== Install MySQL On Slackware ======
  
-===== Install MySQL =====+===== Installing MySQL ===== 
 +Install MySQL from the official Slackware discs or using [[slackware:slackpkg|slackpkg]]. If you performed a full install of Slackware, then you already have MySQL on your computer.
  
-Install MySQL from the official Slackware discs or using [slackpkg].+===== Configuring MySQL =====
  
 +  - Create the needed database(s) and set their permissions properly \\ As root, run: <code>
 +root@darkstar# mysql_install_db --user=mysql
 +</code> The user specified by ''--user'' will own the database files, so it's important to set the right user here, otherwise MySQL won't be able to write to your databases. By default MySQL in Slackware runs as user "mysql", so that is the safe choice.
 +  - Enable execution of the //rc script// to start MySQL automatically on boot \\ //This is optional.// <code>
 +root@darkstar# chmod 755 /etc/rc.d/rc.mysqld
 +</code>
 +  - 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.mysqld'': <file sh rc.mysqld>
 +#SKIP="--skip-networking"
 +</file>
 +  - Start mysqld <code>
 +root@darkstar# /etc/rc.d/rc.mysqld start
 +</code> and proceed to the next section "Securing MySQL".
  
-===== Configure MySQL =====+===== Securing MySQL =====
  
-== 1) Create the needed database(s) and set their permissions properly == +<note>You have a choice Manual or Automatic configuration of secure access</note>
-As root, run: +
-     mysql_install_db --user=mysql+
  
-User specified by ''--user'' will own database files, so it's important to set right user hereotherwise MySQL won't be able to write to database. By default MySQL in Slackware runs as user "mysql", so it's safe choice.   +==== Automatic configuration of secure access ==== 
 +  Run the following commandand answer the questions <code> 
 +root@darkstar# /usr/bin/mysql_secure_installation 
 +</code> // The initial root password is "" (the empty string), so just hit <key>ENTER</key> when the above command asks for the password//
  
-== 2) Enable execution of rc script to start MySQL automatically on boot == +==== Manual configuration of secure access ====
-This is optional. +
-     chmod 755 /etc/rc.d/rc.mysqld+
  
-== 3) Enable networking if needed ==+  - Set a password for MySQL's root account <code> 
 +root@darkstar# mysqladmin -u root password 'new-password-here' 
 +</code> If you enabled networking, you should also run this command: <code> 
 +root@darkstar# mysqladmin -u root -h 'your-hostname' password 'new-password' 
 +</code> 
 +<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>
  
-Networking is disabled by default to improve security. If you want to allow network connections, comment out this line in /etc/rc.d/rc.mysqld +===== Connecting to your MySQL server =====
-     #SKIP="--skip-networking" +
-  +
-== 4) Start mysqld ==+
  
-     /etc/rc.d/rc.mysqld start+  - Connect to your MySQL server using the following command <code> 
 +user@darkstar$ mysql -u root -p 
 +</code> 
 +  - For security reasons you should delete the anonymous user 
 +    * For the localhost server: <code> 
 +mysql> use mysql 
 +mysql> SELECT user, host FROM user; 
 +mysql> DELETE FROM user WHERE host='localhost' AND user=''; 
 +</code> 
 +    * 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>
  
-<note>Now you have a choice : Manual Install or Automatic</note>+==== Adding Unicode support ==
  
-== AUTOMATIC ==+  - Change directory to the ''/etc/'' directory, and select the configuration which you prefer. For a "simple" database service without heavy MySQL load, it is recommended to use "''my-large.cnf''" if you have 2 GB of RAM or more. Copy the configuration file you chose and name the copy ''/etc/my.cnf''
 +  - Edit ''/etc/my.cnf'' adding these lines in the section "''[mysqld]''": <code> 
 +[mysqld] 
 +collation-server utf8_unicode_ci 
 +init-connect='SET NAMES utf8' 
 +character-set-server utf8 
 +</code> This gives you full UTF8 support in your MySQL server, after you restarted it.
  
-== 5) 6) 7) Run the following, answer the questions == +More on Unicode / UTF8 character set support is described here: [[http://stackoverflow.com/questions/3513773/change-mysql-default-character-set-to-utf8-in-my-cnf]]
- +
-     /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' +
- +
-If you enabled networking, you should also run this command: +
- +
-     mysqladmin -u root -h 'your-hostname' password 'new-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> +
- +
-== 6) Connect to your MySQL server == +
-     mysql -u root -+
- +
- +
-== 7) For security reasons you should delete the anonymous user for localhost server == +
- +
-     mysql> use mysql +
-     mysql> SELECT user, host FROM user; +
-     mysql> DELETE FROM user WHERE host='localhost' AND user='';+
  
 ===== Troubleshooting ===== ===== 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>CTRL+\</key> to stop the server). Run: 
- 
-     /usr/bin/mysqld_safe --console 
- 
-  * 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'; +  * 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> 
-     FLUSH PRIVILEGES;+root@darkstar# /usr/bin/mysqld_safe --console 
 +</code>
  
-Save this file (any name would do) and start the server with the --init-file argument: +  * 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): <file sql mysql_new.cnf> 
-   +UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; 
-     /usr/bin/mysqld_safe --defaults-file="new_cnf_file.cnf" +FLUSH PRIVILEGES; 
-  +</file> Save this file (any name would do) and start the server with the --init-file argument: <code> 
 +root@darkstar# /usr/bin/mysqld_safe --defaults-file="new_cnf_file.cnf" 
 +</code>
  
 ====== Sources ====== ====== Sources ======
Line 83: Line 92:
  
 <!-- 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 --> +{{tag>howtos software mysql database author_arfon needs_content}}
-{{tag>howtos software mysq author_arfon}}+

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