[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

Both sides previous revisionPrevious revision
Next revision
Previous revision
howtos:databases:install_mysql_on_slackware [2013/01/06 04:05 (UTC)] – added REVIEWED comment mfillpothowtos:databases:install_mysql_on_slackware [2013/02/12 11:31 (UTC)] (current) – Layout changes (proper heading/enumeration) and use of correct english in the new UTF8 section. alienbob
Line 1: Line 1:
 <!-- Reviewed 2012-01-05 mfillpot --> <!-- Reviewed 2012-01-05 mfillpot -->
-<!-- Add your text below. We strongly advise to start with a Headline (see button bar above). -->+<!-- 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 +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.
-[[slackware:slackpkg|slackpkg]].+
  
-===== Configure MySQL ===== +===== Configuring MySQL ===== 
-== 1) Create the needed database(s) and set their permissions properly == + 
-As root, run: +  - Create the needed database(s) and set their permissions properly \\ As root, run: <code>
-<code>+
 root@darkstar# mysql_install_db --user=mysql root@darkstar# mysql_install_db --user=mysql
-</code> +</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>
-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'the safe choice. +
- +
-== 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 root@darkstar# chmod 755 /etc/rc.d/rc.mysqld
 </code> </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>
-== 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.mysqld'' +
-<file>+
 #SKIP="--skip-networking" #SKIP="--skip-networking"
 </file> </file>
-  +  - Start mysqld <code>
-== 4) Start mysqld == +
-<code>+
 root@darkstar# /etc/rc.d/rc.mysqld start root@darkstar# /etc/rc.d/rc.mysqld start
-</code>+</code> and proceed to the next section "Securing MySQL".
  
-<note> +===== Securing MySQL ===== 
-Now you have a choice : Manual Install or Automatic + 
-</note>+<note>You have a choice : Manual or Automatic configuration of secure access</note>
  
-== AUTOMATIC == +==== Automatic configuration of secure access ==== 
-== 5) 6) 7) Run the following, answer the questions == +  - Run the following commandand answer the questions <code>
-<code>+
 root@darkstar# /usr/bin/mysql_secure_installation root@darkstar# /usr/bin/mysql_secure_installation
-</code> +</code> // The initial root password is "" (the empty string)so just hit <key>ENTER</key> when the above command asks for the password//
-// Initial root password is "" so, just hit <key>ENTER</key>//+
  
-== MANUAL ==+==== Manual configuration of secure access ====
  
-== 5) Set a password for MySQL's root password == +  - Set a password for MySQL's root account <code>
-<code>+
 root@darkstar# mysqladmin -u root password 'new-password-here' root@darkstar# mysqladmin -u root password 'new-password-here'
-</code> +</code> If you enabled networking, you should also run this command: <code>
- +
-If you enabled networking, you should also run this command: +
-<code>+
 root@darkstar# mysqladmin -u root -h 'your-hostname' password 'new-password' root@darkstar# mysqladmin -u root -h 'your-hostname' password 'new-password'
 </code> </code>
- 
 <note tip> <note tip>
-Check the ''mysql_install_db'' results, these commands are printed, you can +Check the ''mysql_install_db'' results, these commands are printed, you can copy/paste them. The hostname will already be replaced by yours.
-copy/paste them. The hostname will already be replaced by yours.+
 </note> </note>
  
-== 6) Connect to your MySQL server == +===== Connecting to your MySQL server ===== 
-<code>+ 
 +  - Connect to your MySQL server using the following command <code>
 user@darkstar$ mysql -u root -p user@darkstar$ mysql -u root -p
 </code> </code>
- +  - For security reasons you should delete the anonymous user 
- +    For the localhost server: <code>
-== 7) For security reasons you should delete the anonymous user == +
-For the localhost server: +
- +
-<code>+
 mysql> use mysql mysql> use mysql
 mysql> SELECT user, host FROM user; mysql> SELECT user, host FROM user;
 mysql> DELETE FROM user WHERE host='localhost' AND user=''; mysql> DELETE FROM user WHERE host='localhost' AND user='';
 </code> </code>
- +    * If you enabled networking, you should run this command instead: <code>
-If you enabled networking, you should run this command instead: +
-<code>+
 mysql> use mysql mysql> use mysql
 mysql> SELECT user, host FROM user; mysql> SELECT user, host FROM user;
 mysql> DELETE FROM user WHERE user=''; mysql> DELETE FROM user WHERE user='';
 </code> </code>
 +
 +==== Adding Unicode support ==
 +
 +  - 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.
 +
 +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]]
  
 ===== 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>C-\</key> to stop the server). Run: + 
-<code>+  * 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 root@darkstar# /usr/bin/mysqld_safe --console
 </code> </code>
  
-  * 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): +  * 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>
-<file>+
 UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
 FLUSH PRIVILEGES; FLUSH PRIVILEGES;
-</file> +</file> Save this file (any name would do) and start the server with the --init-file argument: <code>
- +
-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" root@darkstar# /usr/bin/mysqld_safe --defaults-file="new_cnf_file.cnf"
 </code> </code>
Line 113: 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 mysql database author_arfon needs_content}}
 howtos:databases:install_mysql_on_slackware ()