js

Monday, December 16, 2024

Install mySQL8 in ubuntu

 

To install MySQL 8 on an Ubuntu system, follow these steps:


Step 1: Update System Packages

Update the package index to ensure your system is up-to-date.

sudo apt update
sudo apt upgrade -y

Step 2: Install MySQL APT Repository

Ubuntu's default repository may not include MySQL 8. To get MySQL 8, you need to download the MySQL APT repository.

  1. Download the repository package:
wget https://dev.mysql.com/get/mysql-apt-config_0.8.29-1_all.deb
  1. Install the downloaded package:
sudo dpkg -i mysql-apt-config_0.8.29-1_all.deb
  1. During installation:
    • You will see a configuration screen.
    • Select MySQL Server & Cluster (currently MySQL 8.0).
    • Press OK to continue.

Step 3: Install MySQL Server

Once the repository is set up, install MySQL 8:

sudo apt update
sudo apt install mysql-server -y

Step 4: Secure MySQL Installation

After installation, secure the MySQL setup using the following command:

sudo mysql_secure_installation

You will be prompted to:

  • Set a root password.
  • Remove anonymous users.
  • Disable root login remotely.
  • Remove test databases.
  • Reload privileges.

Answer Y (yes) to all prompts for a secure configuration.


Step 5: Verify MySQL Service

  1. Ensure MySQL is running:
sudo systemctl status mysql
  1. Enable MySQL to start on boot:
sudo systemctl enable mysql

Step 6: Connect to MySQL

You can connect to MySQL as the root user:

sudo mysql -u root -p

Enter the root password you set earlier.


Optional: Allow Remote Access

If you want to allow remote connections to your MySQL server:

  1. Edit the MySQL configuration file:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
  1. Find the line with bind-address and change it to:
bind-address = 0.0.0.0
  1. Restart MySQL:
sudo systemctl restart mysql
  1. Open MySQL and grant remote access:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
  1. Allow MySQL port (3306) through the firewall:
sudo ufw allow 3306

Final Notes

You now have MySQL 8 installed and running on Ubuntu. You can start creating databases, users, and tables.

Let me know if you encounter any issues! 🚀

No comments:

Post a Comment

Importent softwares to install for Developers after installing UBUNTU

PHP sudo apt install php libapache2-mod-php MYSQL sudo apt install mysql-server Install . deb file in ubuntu sudo dpkg -i package-name.deb