Last active
May 9, 2017 10:25
-
-
Save f9n/bb56035e78ae1838a3fe5ea43f6bdfb1 to your computer and use it in GitHub Desktop.
Mysql Instructions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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