Setting up a MySQL database
This post is just for future reference with a few MySQL commands I can’t really remember yet for creating a new database and mysql user. Probably now I posted them here, I will remember them ;). So it might be interesting or less interesting for you.
First, login as root with:
mysql -u root -p
If you forgot your root password, follow these steps:
sudo service mysql stop
sudo mysqld --skip-grant-tables &
mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root';
mysql> FLUSH PRIVILEGES; exit;
When logged in, create a new database:
CREATE DATABASE databasename;
And create a user for it, if we want a separate user at least:
GRANT ALL ON databasename.* TO myuser@localhost IDENTIFIED BY 'mypassword';
And that’s usually what you need to know.