Skip to content

Instantly share code, notes, and snippets.

@f9n
Last active May 9, 2017 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save f9n/bb56035e78ae1838a3fe5ea43f6bdfb1 to your computer and use it in GitHub Desktop.
Save f9n/bb56035e78ae1838a3fe5ea43f6bdfb1 to your computer and use it in GitHub Desktop.
Mysql Instructions
# Installing Mysql
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| (bash)$ pacman -S mysql |
| (bash)$ mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql |
| (bash)$ sudo systemctl start mysqld |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
# Accesing Mysql
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| (bash)$ mysql -u root -p |
| mysql> |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
# Create a database and assign a User
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| mysql> CREATE DATABASE <TestDb>; |
| mysql> CREATE USER '<Username>'@localhost IDENTIFIED BY '<Password>'; |
| mysql> GRANT ALL PRIVILEGES ON <TestDb>.* TO '<Username>'@localhost; |
| mysql> exit |
| (bash)$ mysql -u <Username> -p |
| Enter password: <Password> |
| mysql> show databases; |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
# Change a User Password (One Way)
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| (bash)$ mysql -u root -h localhost -p |
| mysql> use mysql; |
| mysql> SET PASSWORD FOR '<user-name>'@'<hostname-name>' = PASSWORD('<new-password>'); |
| mysql> FLUSH PRIVILEGES; |
| mysql> quit; |
| (bash)$ mysql -u <user-name> -p |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
# Change a User Password (Two Way)
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| (bash)$ mysql -u root -h localhost -p |
| mysql> use mysql; |
| mysql> UPDATE mysql.user SET Password=PASSWORD('<new-password>') WHERE USER='<user-name>' AND Host='<host-name>';|
| mysql> FLUSH PRIVILEGES; |
| mysql> quit; |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
# Source
https://www.linode.com/docs/databases/mysql/using-mysql-relational-databases-on-arch-linux/
https://www.cyberciti.biz/faq/mysql-change-user-password/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment