After creating new droplet, how can I install mysql in the newly created droplet as assigning IP address itself take more seconds. Please advice
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
<blockquote>assigning IP address itself take more seconds. </blockquote>What do you mean? <br> <br>We have plenty of articles on installing and setting up MySQL on a droplet: <a href=“https://www.digitalocean.com/community/community_tags/mysql”>https://www.digitalocean.com/community/community_tags/mysql</a>.
To install MySQL on a new DigitalOcean droplet (assuming you’re using an Ubuntu droplet), follow the steps below. The instructions are based on Ubuntu 22.04 LTS but should work with minor adjustments for other Ubuntu versions.
Log into your Droplet
Use SSH to log into your droplet:
ssh root@YOUR_DROPLET_IP
It’s a good practice to make sure your system packages are up-to-date before installing any new software:
sudo apt update
sudo apt upgrade
Use the apt package manager to install the MySQL server:
sudo apt install mysql-server
Run the included security script. This will remove some insecure default settings and lock down access to the database system:
sudo mysql_secure_installation
You will be prompted to answer a few questions:
- **Validate password component**: You can choose yes to enforce strong password policies for MySQL users, or choose no if you'd prefer to set your own password standards.
- **Set a password for the MySQL root user**.
- **Remove anonymous users**: Recommended to choose "Yes".
- **Disallow root login remotely**: Recommended to choose "Yes".
- **Remove test database and access to it**: Choose "Yes".
- **Reload privilege tables now**: Choose "Yes".
Test the MySQL Installation
Access the MySQL shell:
sudo mysql -u root -p
You’ll be prompted to enter the password for the MySQL root user that you set up during the security script. After entering the correct password, you should see the MySQL prompt.
Adjust User Authentication and Native Password Plugin (if needed)
Starting from MySQL 5.7, the root MySQL user uses the auth_socket plugin by default. If you want to access the database with the root user using a password, you’ll need to change its authentication method:
ALTER USER 'root'@'localhost' IDENTIFIED WITH 'mysql_native_password' BY 'YOUR_PASSWORD';
FLUSH PRIVILEGES;
Replace YOUR_PASSWORD with your desired password.
8. **Enable and Start the MySQL Service**
If MySQL isn't running, start it with:
```bash
sudo systemctl start mysql
Enable MySQL to start on boot:
sudo systemctl enable mysql
Your MySQL server should now be installed and secured. From here, you can start creating databases, adding users, and performing other database administration tasks. Remember to regularly back up your databases and monitor the MySQL server for security and performance.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.