Install MySQL on Ubuntu And Skip the Password Prompt

When you install mysql on Ubuntu (I use 16.04), it requires you to fill the admin password for the first time before finishing the installation. This prompt will wait the user input until you fill the password.

This trick is very helpful if you want to install mysql in Dockerfile, and skipping the password prompt:

$ export DEBIAN_FRONTEND=noninteractive
$ sudo -E apt-get -q -y install mysql-server

Grant remote access permission to MySQL server

Login to your mysql/mariadb console:

sudo mysql -u <user> -p

Run this command:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'YoUrP45sw0rd!' WITH GRANT OPTION;

Don’t forget to flush the privileges

FLUSH PRIVILEGES;

If user still cannot see the tables, try to disconnect mysql and reconnect again.

WordPress still cannot Establishing a Database Connection – Error

Have you ever experiencing this problem like this? after your install wordpress, setup anything, webserver, database, everything is completed. Yet, wordpress still cannot establishing your database connection.

Eventhough you’ve already make sure that your database is up and running (I’m using MySQL) and your port is already open, though.

Trust me! I’ve done anything properly, I spent hours just to figure out what the root cause was and after some googling and stackoverflowing, I found this problem was due to SE in linux.

$ sudo setsebool -P httpd_can_network_connect_db=1

Thanks in advance SElinux!

Django table is marked as crashed and should be repaired

My django app is showing 500 because one of the tables in database marked crashed and should be repaired.

InternalError at /

(145, "Table './dbname/django_session' is marked as crashed and should be repaired")

I thought it was just an usual error from mysql and needed to restart but it wasn’t.

Solutions:

 Login to mysql, select your dbname, and use this command:

USE user_base;
REPAIR TABLE TABLE;