[2025-jun-17] The SlackDocs mailing lists at https://lists.alienbase.nl/mailman/listinfo have been retired. No one has been using these lists for years and it's time to say goodbye. The list archives remain available at https://scalzi.slackware.nl/mailman/listinfo/slackdocs

[2025-jun-17] The SlackDocs Wiki has moved to a new server, in order to make it more performant.

Welcome to the Slackware Documentation Project

¡Esta es una revisión vieja del documento!


“Work in progress (antares_alf)”

Instalar MySQL en Slackware

Instalación de MySQL

Instalar MySQL desde los discos oficiales de Slackware usando slackpkg. Si realizó una instalación completa de Slackware, entonces ya tiene MySQL en su computadora.

Configurar MySQL

  1. Cree la(s) base(s) de datos necesaria(s) y establezca sus permisos correctamente
    Como root, ejecute:
    root@darkstar# mysql_install_db --user=mysql

El usuario especificado por –user será el propietario de los archivos de la base de datos, por lo que es importante establecer el usuario correcto, de lo contrario, MySQL no podrá escribir en sus bases de datos. De forma predeterminada, MySQL en Slackware se ejecuta como usuario “mysql”, por lo que esa es la opción segura.

  1. Habilite la ejecución del script rc script para iniciar MySQL automaticamente en el arranque
    Esto es opcional.
    root@darkstar# chmod 755 /etc/rc.d/rc.mysqld
  2. Habilite las redes si es necesario
    Las redes están deshabilitadas de forma predeterminada para mejorar la seguridad. Si desea permitir conexiones de red, comente esta línea en /etc/rc.d/rc.mysqld:
    rc.mysqld
    #SKIP="--skip-networking"
  3. Iniciar mysqld
    root@darkstar# /etc/rc.d/rc.mysqld start

    y proceda a la sección “Seguridad de MySQL”.

Seguridad de MySQL

Tienes una opción: configuración manual o automática de acceso seguro.

Configuración automática de acceso seguro.

  1. Ejecute el siguiente comando, y responda las pregruntas
    root@darkstar# /usr/bin/mysql_secure_installation

    La contraseña inicial de root es “” (una cadena vacía), así que solo presione ENTER cuando el comando anterior solicita la contraseña.

Manual configuration of secure access

  1. Set a password for MySQL's root account
    root@darkstar# mysqladmin -u root password 'new-password-here'

    If you enabled networking, you should also run this command:

    root@darkstar# mysqladmin -u root -h 'your-hostname' password 'new-password'
Check the mysql_install_db results, these commands are printed, you can copy/paste them. The hostname will already be replaced by yours.

Connecting to your MySQL server

  1. Connect to your MySQL server using the following command
    user@darkstar$ mysql -u root -p
  2. For security reasons you should delete the anonymous user
    • For the localhost server:
      mysql> use mysql
      mysql> SELECT user, host FROM user;
      mysql> DELETE FROM user WHERE host='localhost' AND user='';
    • If you enabled networking, you should run this command instead:
      mysql> use mysql
      mysql> SELECT user, host FROM user;
      mysql> DELETE FROM user WHERE user='';

Adding Unicode support

  1. 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.
  2. Edit /etc/my.cnf adding these lines in the section “[mysqld]”:
    [mysqld]
    collation-server = utf8_unicode_ci
    init-connect='SET NAMES utf8'
    character-set-server = utf8

    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

  • 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 Ctrl+\ to stop the server). Run:
    root@darkstar# /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):
    mysql_new.cnf
    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:

    root@darkstar# /usr/bin/mysqld_safe --defaults-file="new_cnf_file.cnf"

Sources

QR Code
QR Code es:howtos:databases:install_mysql_on_slackware (generated for current page)