MySQL 5.7 on Ubuntu-Debian installation troubleshooting

apt does not do a good job managing different versions.

Hence, there is a specific configuration tool, if you want to install a different version than the latest, called mysql-apt-config - that you need to install manually.

sudo wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.23-1_all.deb sudo dpkg -i mysql-apt-config_0.8.23-1_all.deb

When it asks, you probably want to go with the latest OS version your system has, in my case for popOS 22, it was bionic release.

Select the correct version, run

sudo apt update

then check if it got added to your sources properly:

sudo apt-cache policy mysql-server

You should see the correct version listed there. If you mistakenly add the wrong version, you can still go and find the entries inside your sources list ->

sudo nano /etc/apt/sources.list.d/mysql.list

just change the release code name to the one desired, then rerun sudo apt update. Now you can try installing:

sudo apt install -f mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7*

Note: fish does not like the stars (*) so use the built in gnome terminal.

If the install fails, try purging everything, and then remove any remnant files from the folders:

sudo apt purge mysql-client mysql-apt-config mysql-common mysql-community-client

Is there anything remaining there?

ls /etc/mysql

if yes, delete it and start over.

Other useful MySQL commands

Query to check the flags that mysql is operating with: SELECT @@sql_mode; Query to update the flags: SET sql_mode = 'new_sql_mode_flags';

Add new superuser

Since a while, you can not simply use root for accessing even your local env. In order to sign in, you need to use sudo mysql.

To add a new user with all privileges:

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
FLUSH PRIVILEGES;