Skip to main content

Featured

Install Apache 2 on Ubuntu 24.04

Apache2 is one of the most popular and reliable open-source web servers. If you’re running Ubuntu 24.04 and want to host websites or applications, Apache2 is an excellent choice. In this guide, you’ll learn how to install and configure Apache2 step by step.

Install and Configure MySQL 8.0 on Ubuntu 24.04

MySQL is one of the most popular relational database management systems in the world. It is widely used for applications, websites, and services that require structured data storage. In this tutorial, you will learn how to install and configure MySQL 8.0 on Ubuntu 24.04, secure the installation, and create a dedicated administrative user.

Update Your Package Index

Start by updating the package list to make sure you are installing the latest version available:

sudo apt update

Install MySQL Server

Run the following command to install MySQL 8.0:

sudo apt install mysql-server

Start the MySQL Service

Enable and start the MySQL service with:

sudo systemctl start mysql.service

Access the MySQL Shell

Enter the MySQL shell as the root user:

sudo mysql

Set a password for the root user (replace mysecretpassword with your custom password):

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysecretpassword';

Exit the MySQL shell:

exit

Secure the MySQL Installation

MySQL includes a script to improve the default security. Run the following command:

sudo mysql_secure_installation

During the setup:

  • For the first two questions, choose No.
  • For the remaining questions, choose Yes to improve security.

Log in With Root Password

Now log in using the root account and the password you set earlier:

mysql -u root -p

Switch Root Back to auth_socket (Optional)

If you want root to authenticate with auth_socket instead of a password, run the following inside MySQL:

ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;

Create a New Admin User

It’s a good practice to create a new administrative user instead of using root for daily operations. Run the following (replace mysecretpassword with your own secure password):

CREATE USER 'admin'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysecretpassword';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;

Exit the MySQL shell:

exit

Conclusion

You have successfully installed and configured MySQL 8.0 on Ubuntu 24.04. You secured the installation, set a root password, and created a dedicated administrative user. Your database server is now ready for use in applications, development, or production environments.

Comments

Popular Posts