Enjoy the Holiday season!

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
Last revision Both sides next 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/11 16:51 (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 
-Install MySQL from the official Slackware discs or using [slackpkg]. +[[slackware:slackpkg|slackpkg]].
  
 ===== Configure MySQL ===== ===== Configure MySQL =====
- 
 == 1) Create the needed database(s) and set their permissions properly == == 1) Create the needed database(s) and set their permissions properly ==
 As root, run: As root, run:
-     mysql_install_db --user=mysql+<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 safe choice.   +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 == == 2) Enable execution of rc script to start MySQL automatically on boot ==
-This is optional. +//This is optional.// 
-     chmod 755 /etc/rc.d/rc.mysqld+<code> 
 +root@darkstar# chmod 755 /etc/rc.d/rc.mysqld 
 +</code>
  
 == 3) Enable networking if needed == == 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 sh rc.mysqld>
 +#SKIP="--skip-networking"
 +</file>
  
-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 
-     #SKIP="--skip-networking" 
-  
 == 4) Start mysqld == == 4) Start mysqld ==
 +<code>
 +root@darkstar# /etc/rc.d/rc.mysqld start
 +</code>
  
-     /etc/rc.d/rc.mysqld start +<note> 
- +Now you have a choice : Manual Install or Automatic 
-<note>Now you have a choice : Manual Install or Automatic</note>+</note>
  
 == AUTOMATIC == == AUTOMATIC ==
- 
 == 5) 6) 7) Run the following, answer the questions == == 5) 6) 7) Run the following, answer the questions ==
- +<code> 
-     /usr/bin/mysql_secure_installation +root@darkstar# /usr/bin/mysql_secure_installation 
-          Initial root password is "" so, just hit <ENTER>+</code> 
 +// Initial root password is "" so, just hit <key>ENTER</key>//
  
 == MANUAL == == MANUAL ==
  
 == 5) Set a password for MySQL's root password == == 5) Set a password for MySQL's root password ==
- +<code> 
-     mysqladmin -u root password 'new-password-here'+root@darkstar# mysqladmin -u root password 'new-password-here' 
 +</code>
  
 If you enabled networking, you should also run this command: If you enabled networking, you should also run this command:
 +<code>
 +root@darkstar# mysqladmin -u root -h 'your-hostname' password 'new-password'
 +</code>
  
-     mysqladmin -u root -h 'your-hostname' password 'new-password' +<note tip> 
- +Check the ''mysql_install_db'' results, these commands are printed, you can 
-<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>+copy/paste them. The hostname will already be replaced by yours. 
 +</note>
  
 == 6) Connect to your MySQL server == == 6) Connect to your MySQL server ==
-     mysql -u root -p+<code> 
 +user@darkstar$ mysql -u root -p 
 +</code>
  
  
-== 7) For security reasons you should delete the anonymous user for localhost server ==+== 7) For security reasons you should delete the anonymous user == 
 +For the localhost server:
  
-     mysql> use mysql +<code> 
-     mysql> SELECT user, host FROM user; +mysql> use mysql 
-     mysql> DELETE FROM user WHERE host='localhost' AND user='';+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> 
 + 
 +== 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. 
 +More on this described there:[[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>CTRL+\</key> to stop the server). Run: +  * 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> 
-     /usr/bin/mysqld_safe --console+root@darkstar# /usr/bin/mysqld_safe --console 
 +</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>
 +UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
 +FLUSH PRIVILEGES;
 +</file>
  
-     UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; +Save this file (any name would do) and start the server with the --init-file 
-     FLUSH PRIVILEGES; +argument: 
- +<code> 
-Save this file (any name would do) and start the server with the --init-file argument: +root@darkstar# /usr/bin/mysqld_safe --defaults-file="new_cnf_file.cnf" 
-   +</code>
-     /usr/bin/mysqld_safe --defaults-file="new_cnf_file.cnf" +
-  +
  
 ====== Sources ====== ====== Sources ======
Line 84: 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)