Skip to content

Instantly share code, notes, and snippets.

@umarov
Last active November 25, 2018 16:28
Show Gist options
  • Save umarov/e5b79acebbfd0eb0c87f0a87fe7ecd32 to your computer and use it in GitHub Desktop.
Save umarov/e5b79acebbfd0eb0c87f0a87fe7ecd32 to your computer and use it in GitHub Desktop.
mysql 5.7 setup
$ sudo mysql -u root # I had to use "sudo" since is new installation
mysql> USE mysql;
mysql> CREATE USER 'YOUR_SYSTEM_USER'@'localhost' IDENTIFIED BY ''; # replace YOUR_SYSTEM_USER with your username
mysql> GRANT ALL PRIVILEGES ON *.* TO 'YOUR_SYSTEM_USER'@'localhost'; # replace YOUR_SYSTEM_USER with your username
mysql> UPDATE user SET plugin='auth_socket' WHERE User='YOUR_SYSTEM_USER'; # replace YOUR_SYSTEM_USER with your username
mysql> FLUSH PRIVILEGES;
# this is the password you need to add to in congfig/database.yml
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PASSWORD'; 
mysql> exit;

If you set the password and forgot to write it down, you can enter mysql without root passwork like this:

$ sudo /usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf
$ service mysql restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment