To install and configure MySQL on Slackware, follow these steps:
Update Your System:
Ensure your Slackware system is up-to-date.
sudo slackpkg update
sudo slackpkg upgrade
Install MySQL:
Use the slackpkg package manager to install MySQL.
sudo slackpkg install mysql-server
Start MySQL Service:
Start the MySQL service and enable it to start on boot.
sudo systemctl start mysqld
sudo systemctl enable mysqld
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.
Login to MySQL:
Use the root account to log in to the MySQL shell.
sudo mysql -u root -p
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;
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.
[mysqld]
bind-address = 127.0.0.1
max_connections = 200
innodb_buffer_pool_size = 1G
After making changes to the configuration file, restart the MySQL service.
sudo systemctl restart mysqld
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.