Problem installing MySQL in Fedora 31

Hello Fedorans,

I have recently installed Fedora 31. Everything is going good and fine except for being able to get MySQL to work. I was following https://www.if-not-true-then-false.com/2010/install-mysql-on-fedora-centos-red-hat-rhel/ to install MySQL on my machine but it didn’t work. Whenever I issue the command

sudo systemctl start mysqld.service

my computer hangs for about 5 mins. It then works sluggishly. Even rebooting the computer takes a long time. To understand the problem, I issued the command

systemctl status mysqld.service

and here is it’s output:

Upon reading about this problem on some forums, I issued the command

sudo systemctl start mariadb.service

but I got the message “Failed to enable unit: Unit file mariadb.service does not exist.”

What should I do to get MySQL up and running on my system? I was using it perfectly with Fedora 30 but now, after the fresh install of Fedora 31, I can’t seem to make it work.

Thanking you in anticipation.

You did do a mysqld --initialize ? mysql just needs it own database do work succesfully. used to be a seperate command ‘mysql_install_db’ in the olden days…

Hope this helps.

@eulijn No, I did not do so. Could you please tell me the whole command which I need to type after running

sudo dnf install mysql-community-server

Hello Fedorans,

After installing Fedora 31 and performing the necessary tasks to get it up and running, I tried to install MySQL. I followed https://computingforgeeks.com/how-to-install-mysql-8-on-fedora to install Mysql. However, when I issued sudo systemctl start mysqld.service, my computer just froze for about 2-3 mins and when it unfroze, it ran extremely slow. I rebooted the machine, but the boot process also seems to have been broken/affected. After boot up I issued sudo systemctl status mysqld.service but it gave me the following error:

Not only this, but my boot time has increased substantially(near about 5 mins). During the boot up process, the machine often crashes. How do I solve this issue? What is the correct method to get MySQL 8 working?

Thank you all for your help.

@c2ycharlie, Here are some things we have to shuffle, it happen to me too, GNOME freeze and take forever to login:

  1. systemctl status mysqld.service, This information doesn’t explain wheel the problem, after this command you should type journalctl -xe and provide all information necessary provide by this command.
  2. You can install a mysql from the :fedora: main repo, a mysql provide by the community, it version is community-mysql-8.0.17-2.fc31 you can install just typing:
    • sudo dnf install community-mysql-server
  3. Depend of your needs you can use container, like podman:

Install

The process should be very simple:

  1. Adding the MySQL repository to Fedora 31
sudo dnf install https://repo.mysql.com//mysql80-community-release-fc31-1.noarch.rpm
  1. Installing MySQL on Fedora 31
sudo dnf install mysql-community-server
  1. Start MySQL Service and Enable at Loggin:
sudo systemctl start mysqld
sudo systemctl enable mysqld
  1. Find Default Password:

For security reasons, MySQL generates a temporary root key. Please note that MySQL has even stricter security policies than MariaDB.

Then, you have to show which is the temporary password generated to be able to run the mysql_secure_installation script and be able to set a definite root key.

sudo cat /var/log/mysqld.log

and find something like temporary password generated.

  1. Configuring MySQL before the first use
sudo mysql_secure_installation

Then, answer the security questions as you prefer. or just yes to all of them.

  1. using MYSQL
sudo mysql -u root -p
  1. Removing MySQL

I suggest to remove in the following way, the most appropriate and safe way without removing many dependencies is:

mysql-community-libs-8.0.18-1.fc31.x86_64
mysql-community-common-8.0.18-1.fc31.x86_64
mysql-community-server-8.0.18-1.fc31.x86_64

sudo rpm -e --nodeps mysql-community-libs mysql-community-common mysql-community-server

Regards.,

3 Likes

Hey @hhlp, what about writing a quick-doc? :wink:

2 Likes

Hey @hhlp, in your quick tips point number 2, you tell me to use community-mysql from fedora repos but in the install steps you are again adding the repos and using mysql-community-server. Why so? Moreover, the install process listed by you is the exact process which I followed which caused the freeze. Could you please look into it? Thanking you in anticipation.

Out of curiosity, have you installed mariadb before installing mysql?

uninstall:

sudo rpm -e --nodeps mysql-community-server mysql-community-common mysql-community-libs

disable it mysql oracle repo :fedora:

sudo dnf config-manager --disable mysql80-community

and install the community

sudo dnf install community-mysql-server

Regards.,

1 Like

@alciregi No I haven’t. Do I need to? What are the advantages of mariadb over mysql?

@hhlp Thank you so much. I really appreciate it.

Just to be clear, after running sudo dnf install community-mysql-server, will I have to run the following commands too?

sudo systemctl start mysqld 
sudo systemctl enable mysqld

No no. It was just to be sure that there are not conflicting stuff around.

1 Like

I can’t reproduce your issue in a virtual machine, I recommend to you uninstall and install the community from fedora repo… as i said

Until I found the issue

when you type this command the system hangs…

Regards.,

1 Like

@c2ycharlie could you look in the mysql log file? It should be located in /var/log/mysql

1 Like

the proper way is start the service and see what journalctl -xe say about it, systemctl status doesn’t provide much help here, is your system doesn’t freeze like me, reboot doesn’t help too, I have to recover from a LIVE/CD…

Regards.,

1 Like

@hhlp @alciregi thank you both for your continuous support and guidance. I tried to run sudo dnf install community-mysql-server. It ran perfectly. However, when I tried to run sudo systemctl start mysqld.service, it failed again, although the system didn’t crash like previous time. Tired of it all, I have decided to switch to MariaDB. Installed it just a few hours ago, seems to be working fine.

the reason is for compatiblity problem:

  • community version is 8.0.17
  • oracle version 8.018

if your database is empty: just type:

sudo rm -rf /var/lib/mysql/

otherwise you should use mysqldump.

Regards.,

1 Like

@hhlp So, I performed the following steps:

sudo dnf remove mariadb-server mariadb
sudo dnf install community-mysql-server
sudo rm -rf /var/lib/mysql
sudo systemctl start mysqld.service

It executed properly except for the last line. This is the error:

What should I do? To clarify, I have chosen community-mysql-server from fedora repos because mysql repo was creating issues for me.

Thanks in advance.

Ups., hehe @c2ycharlie

sudo dnf remove mariadb-server mariadb
sudo dnf install community-mysql-server
sudo rm -rf /var/lib/mysql
sudo systemctl start mysqld.service

Log’s

[Server] Can't create test file /var/lib/mysql/

you delete the directory before not after:

however systemctl status don’t provide enough information, just execute after systemctl start the command:

journalctl -xe -u mariadb -u mysqld

bad order, correct one:

sudo dnf remove mariadb-server mariadb
sudo rm -rf /var/lib/mysql
sudo dnf install community-mysql-server
sudo systemctl start mysqld.service

this command resolve your issues…

sudo dnf reinstall community-mysql-server

Regards.,

3 Likes

@hhlp Thank you so much man! Thanks a ton! Your solution worked. Even when I had given up hope, you kept helping me and the result was worth it. Once again man, thank you a lot!

3 Likes