Install with APT repository
- First determine version you like and go to https://dev.mysql.com/downloads/repo/apt/
- At this time, there is only one option: mysql-apt-config_0.8.22-1_all.deb – which seems to be MySql 8.0, note the file name.
- Now, get the deb file like so:
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb - Next launch config tool like so:
dpkg -i mysql-apt-config_0.8.22-1_all.deb - It should launch a UI interface, choose appropriate versions and select OK in the last screen that shows your selections and then click bottom OK button.
- Now apt has stored your selections, next pull down those selections by running
apt-get update - Install Mysql Server with:
apt-get install mysql-server
You will see a number of lines like below:
Preparing to unpack …/00-mysql-common_8.0.28-1ubuntu18.04_amd64.deb …
Unpacking mysql-common (8.0.28-1ubuntu18.04) … - Answer Screen prompt by entering and confirming passwords, choose Strong Password Encryption and click ok. It should do the below:
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Setting up mysql-server (8.0.28-1ubuntu18.04) …
Processing triggers for man-db (2.8.3-2ubuntu0.1) …
Processing triggers for libc-bin (2.27-3ubuntu1.5) … - Run security utility and follow the prompts
mysql_secure_installation - Our source and credit to : https://phoenixnap.com/kb/how-to-install-mysql-on-ubuntu-18-04
Install with TAR file
Installing MySQL 8 (reference: https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html)
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz
tar xvf mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz
mv mysql-8.0.26-linux-glibc2.12-x86_64 /opt/mysql8
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
[Because the user is required only for ownership purposes, not login purposes, the useradd command uses the -r and -s /bin/false options to create a user that does not have login permissions to your server host.]
chown -R mysql:mysql /opt/mysql8
chmod 750 /opt/mysql8
[add mysql bin in PATH variable by editing /etc/environment]
Initialize with : mysqld –initialize –user=mysql
If you see lib errors, run below:
apt-get install libaio1 libaio-dev
apt-get install libnuma-dev
If succeeds copy the temporary password, generated during start up.
Start mysql with:
mysqld_safe –user=mysql &
login with root and the temporary password generated.
Change the password like so:
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘root-password’;