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
Set root password MySQL for the first time:
$ mysqladmin -u root password NEWPASSWORD
Change your existing root password:
$ mysqladmin -u root -p'oldpassword' password newpass
$ sudo vim /etc/my.cnf (for mysql)
$ sudo vim /etc/mysql/my.cnf (for mariadb)
Find these variables, and set the value:
skip-grant-tables is optional, though.
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
If user still cannot see the tables, try to disconnect mysql and reconnect again.
Solution: replace utf8mb4 to utf8 in your .sql file
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!
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.
Login to mysql, select your dbname, and use this command:
REPAIR TABLE TABLE;