Skip to content

Instantly share code, notes, and snippets.

@agvxov
Created January 29, 2025 13:09
Show Gist options
  • Save agvxov/1ce26c10441902786c043c1037eb765f to your computer and use it in GitHub Desktop.
Save agvxov/1ce26c10441902786c043c1037eb765f to your computer and use it in GitHub Desktop.
>since MySQL uses an internal system for identifying users a few hoops must be jumped
>root is always preregistered
1. Log in as root
$ sudo mysql
2. Create a new user
CREATE USER '<your_name>'@'localhost' IDENTIFIED BY '<password>';
>NOTE: <password> doesnt have to be the same as the user's system login password
3. Grant privileges to the new user
GRANT ALL PRIVILEGES ON *.* TO '<your_name>'@'localhost';
FLUSH PRIVILEGES;
>NOTE: this grants all privileges, which may not be a very bright idea on a shared system;
granting partial privileges is recommended and detailed BELOW
4. Exit
exit
5. Log in as yourself
mysql --user=<your_username> -p
-NOTE: the following alias is recommended (see AT "/Bash/Builtins/alias")
alias mysql="mysql --user=${USER} -p"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment