Tools: Installing MySQL on Ubuntu 26.04 - 2025 Update

Tools: Installing MySQL on Ubuntu 26.04 - 2025 Update

Install MySQL

Manage the MySQL Service

Secure MySQL

Create a Database and User

Create a Sample Table

Next Steps Ubuntu 26.04 includes MySQL 8.4 in its default APT repository with no third-party sources required. This guide covers installation, service configuration, security hardening with mysql_secure_installation, and creating a database with a scoped user ready for application use. MySQL 8.4 is available directly from Ubuntu 26.04's default APT repository. 1. Update the APT package index: 2. Install the MySQL server package: 3. Verify the installed version: Enable MySQL as a systemd service so it starts automatically on every boot. 1. Enable and start the service: 2. Check the service status: 3. Stop or restart the service when needed: The mysql_secure_installation script removes default configuration risks including anonymous users, remote root login, and the test database. 1. Run the security script: 2. Open the MySQL configuration file: Add the following line under [mysqld]: 3. Restart MySQL to apply the change: 4. Set the root password in the MySQL shell: Log in as root and create a dedicated database with a user scoped to that database only. Log in as the new user to verify database access and permissions. All three rows in the query output confirm the database, user, and table are working correctly. MySQL is now installed and accepting connections. From here you can: For the full guide with additional tips, visit the original article on Vultr Docs. Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Command

Copy

$ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install mysql-server -y $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install mysql-server -y $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install mysql-server -y $ mysql --version $ mysql --version $ mysql --version $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart mysql $ -weight: 600;">sudo mysql_secure_installation $ -weight: 600;">sudo mysql_secure_installation $ -weight: 600;">sudo mysql_secure_installation $ -weight: 600;">sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf $ -weight: 600;">sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf $ -weight: 600;">sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf mysql_native_password=ON mysql_native_password=ON mysql_native_password=ON $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart mysql $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart mysql $ -weight: 600;">sudo mysql $ -weight: 600;">sudo mysql $ -weight: 600;">sudo mysql mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_strong_password'; mysql> FLUSH PRIVILEGES; mysql> EXIT; mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_strong_password'; mysql> FLUSH PRIVILEGES; mysql> EXIT; mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_strong_password'; mysql> FLUSH PRIVILEGES; mysql> EXIT; $ mysql -u root -p $ mysql -u root -p $ mysql -u root -p mysql> CREATE DATABASE myapp_db; mysql> CREATE USER 'myapp_user'@'localhost' IDENTIFIED BY 'user_password'; mysql> GRANT ALL PRIVILEGES ON myapp_db.* TO 'myapp_user'@'localhost'; mysql> FLUSH PRIVILEGES; mysql> EXIT; mysql> CREATE DATABASE myapp_db; mysql> CREATE USER 'myapp_user'@'localhost' IDENTIFIED BY 'user_password'; mysql> GRANT ALL PRIVILEGES ON myapp_db.* TO 'myapp_user'@'localhost'; mysql> FLUSH PRIVILEGES; mysql> EXIT; mysql> CREATE DATABASE myapp_db; mysql> CREATE USER 'myapp_user'@'localhost' IDENTIFIED BY 'user_password'; mysql> GRANT ALL PRIVILEGES ON myapp_db.* TO 'myapp_user'@'localhost'; mysql> FLUSH PRIVILEGES; mysql> EXIT; $ mysql -u myapp_user -p myapp_db $ mysql -u myapp_user -p myapp_db $ mysql -u myapp_user -p myapp_db mysql> CREATE TABLE services ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), -weight: 500;">status VARCHAR(50) ); mysql> INSERT INTO services (name, -weight: 500;">status) VALUES ('web', 'active'), ('db', 'active'), ('cache', 'idle'); mysql> SELECT * FROM services; mysql> EXIT; mysql> CREATE TABLE services ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), -weight: 500;">status VARCHAR(50) ); mysql> INSERT INTO services (name, -weight: 500;">status) VALUES ('web', 'active'), ('db', 'active'), ('cache', 'idle'); mysql> SELECT * FROM services; mysql> EXIT; mysql> CREATE TABLE services ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), -weight: 500;">status VARCHAR(50) ); mysql> INSERT INTO services (name, -weight: 500;">status) VALUES ('web', 'active'), ('db', 'active'), ('cache', 'idle'); mysql> SELECT * FROM services; mysql> EXIT; - Integrate MySQL with an Apache and PHP stack to serve dynamic web applications - Configure replication for read scaling and high availability - Automate backups with mysqldump or Percona XtraBackup