Skip to main content

How to Install MySQL Server on Ubuntu Debian



Run this bash script with sudo on your debian, ubuntu, linux mint and other debian based distros.

install_mysql.sh

#!/bin/bash # Exit immediately if a command exits with a non-zero status set -e # Define MySQL APT Config package URL and file MYSQL_APT_CONFIG_URL="https://dev.mysql.com/get/mysql-apt-config_0.8.33-1_all.deb" MYSQL_APT_CONFIG_DEB="mysql-apt-config_0.8.33-1_all.deb" # Update the package index echo "Updating package index..." sudo apt update -y # Download MySQL APT Config package if [[ ! -f "$MYSQL_APT_CONFIG_DEB" ]]; then echo "Downloading MySQL APT Config package..." wget "$MYSQL_APT_CONFIG_URL" -O "$MYSQL_APT_CONFIG_DEB" fi # Install the MySQL APT Config package echo "Installing MySQL APT Config package..." sudo dpkg -i "$MYSQL_APT_CONFIG_DEB" # Fix missing GPG keys (if any) echo "Updating package index again and fixing missing keys..." sudo apt-key adv --fetch-keys 'https://repo.mysql.com/RPM-GPG-KEY-mysql-2022' sudo apt update -y # Install MySQL Server echo "Installing MySQL Server..." sudo apt install mysql-server -y # Fix MySQL Configuration Issues echo "Fixing potential configuration issues..." # Ensure /etc/mysql/conf.d/ directory exists if [[ ! -d "/etc/mysql/conf.d/" ]]; then echo "Creating missing /etc/mysql/conf.d/ directory..." sudo mkdir -p /etc/mysql/conf.d/ fi # Set correct permissions echo "Setting permissions for /etc/mysql..." sudo chown -R mysql:mysql /etc/mysql/ sudo chmod -R 755 /etc/mysql/ # Disable AppArmor for MySQL (optional) echo "Disabling AppArmor for MySQL..." if [[ -f "/etc/apparmor.d/usr.sbin.mysqld" ]]; then sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ || true sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld || true fi # Restart AppArmor and MySQL echo "Restarting AppArmor and MySQL services..." sudo systemctl restart apparmor || true sudo systemctl restart mysql # Check MySQL status echo "Checking MySQL service status..." sudo systemctl status mysql echo "MySQL installation and configuration completed successfully!" sudo mysql ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; FLUSH PRIVILEGES; exit;

Comments

Popular posts from this blog

How to Install MariaDB / MySQL on Debian 12 - with bash script for apt repo

 Here's a bash script to automate the installation of MariaDB Server on Debian. The script handles both installation from the default Debian repository and from the official MariaDB repository if a newer version is required. Install MariaDB on Linux #!/bin/bash # Bash script to install MariaDB Server on Debian # Function to install MariaDB from the default Debian repository install_from_debian_repo() { echo "Updating package list..." sudo apt update -y echo "Installing MariaDB Server and Client from Debian repository..." sudo apt install -y mariadb-server mariadb-client echo "Starting and enabling MariaDB service..." sudo systemctl start mariadb sudo systemctl enable mariadb echo "Securing MariaDB installation..." sudo mysql_secure_installation echo "MariaDB installed from Debian repository successfully!" } # Function to install MariaDB from the official MariaDB repository inst...

Best Microsoft Office Alternative for Windows & Mac

Best Microsoft Office Alternative for Windows & Mac Best Microsoft Office Alternative for Windows & Mac. Free libre office, open office and only office for windows, mac os x, and linux. GET THEM FROM THESE LINKS Download open office from http://ift.tt/OUGHHi Download Libre Office from http://ift.tt/2jCV6a5 Download the only office from http://ift.tt/2iiKsG7 Related Searches wps office 2016, wps office free, free office 2016, best free office suite, free microsoft office software, office suite free 2013, wps office writer, freeoffice 2016, apache open office, best microsoft office alternative Share this video https://youtu.be/FrS8FtHgtfs