To install and configure MySQL on Raspbian, follow these steps:
Update the System: Before installing MySQL, ensure your system is up to date.
sudo apt-get update
sudo apt-get upgrade
Install MySQL: Use the following command to install MySQL server.
sudo apt-get install mysql-server
Secure MySQL Installation: After installation, run the security script to set up a password for the root user and remove unnecessary features.
sudo mysql_secure_installation
Follow the prompts to set a secure password and configure other security settings.
Start and Enable MySQL Service: Ensure MySQL starts on boot and is running.
sudo systemctl start mysql
sudo systemctl enable mysql
Configure MySQL: You can further configure MySQL by editing its configuration file.
sudo nano /etc/mysql/my.cnf
Make any necessary changes and save the file. After editing, restart MySQL to apply changes.
sudo systemctl restart mysql
Access MySQL: To access the MySQL shell, use:
sudo mysql -u root -p
Enter the password you set during the secure installation.
Example: Suppose you want to create a new database for a web application. In the MySQL shell, you would type:
CREATE DATABASE mydatabase;
For cloud-related services, consider using Tencent Cloud's Cloud Database MySQL, which offers managed MySQL services with high availability and scalability.