Technology Encyclopedia Home >How do I install and configure MySQL on Slackware?

How do I install and configure MySQL on Slackware?

To install and configure MySQL on Slackware, follow these steps:

Installation

  1. Update Your System:
    Ensure your Slackware system is up-to-date.

    sudo slackpkg update
    sudo slackpkg upgrade
    
  2. Install MySQL:
    Use the slackpkg package manager to install MySQL.

    sudo slackpkg install mysql-server
    
  3. Start MySQL Service:
    Start the MySQL service and enable it to start on boot.

    sudo systemctl start mysqld
    sudo systemctl enable mysqld
    

Configuration

  1. Secure MySQL Installation:
    Run the mysql_secure_installation script to set up the root password and remove unnecessary privileges.

    sudo mysql_secure_installation
    

    Follow the prompts to set a strong root password, remove anonymous users, disallow root login remotely, and remove test databases.

  2. Login to MySQL:
    Use the root account to log in to the MySQL shell.

    sudo mysql -u root -p
    
  3. Create a New Database and User:
    Create a new database and user for your application.

    CREATE DATABASE mydatabase;
    CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
    GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
    
  4. Configure MySQL Configuration File:
    Edit the MySQL configuration file to suit your needs. The file is typically located at /etc/my.cnf or /etc/mysql/my.cnf.

    sudo nano /etc/my.cnf
    

    You can add or modify settings such as bind-address, max_connections, and innodb_buffer_pool_size.

Example Configuration Snippet

[mysqld]
bind-address = 127.0.0.1
max_connections = 200
innodb_buffer_pool_size = 1G

Restart MySQL Service

After making changes to the configuration file, restart the MySQL service.

sudo systemctl restart mysqld

Additional Resources

For more advanced configurations and management, consider using Tencent Cloud's Cloud Database MySQL service, which offers managed MySQL instances with high availability, automatic backups, and scalability.

By following these steps, you should have MySQL installed and configured on your Slackware system.