forked from webmentordev/linux-bash-scripts-and-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall MySQL.txt
More file actions
43 lines (40 loc) · 2.11 KB
/
Install MySQL.txt
File metadata and controls
43 lines (40 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
======================================
To Connect Remotely to MySQL
$ sudo apt install mysql-client
======================================
Install MYSQL
$ sudo apt update && sudo apt upgrade
$ sudo apt install mysql-server
$ mysql --version
=======================================
Configure MySQL
$ sudo mysql_secure_installation (Press y, 0/1/2, y)
$ sudo systemctl status mysql
=======================================
Start MySQL & Change Passwords
$ sudo mysql -u root
$ UPDATE mysql.user SET Password = PASSWORD('password') WHERE User = 'root'; (Less then 5.7)
$ UPDATE mysql.user SET authentication_string = PASSWORD('password') WHERE User = 'root'; (Higher then 5.7)
$ SELECT User, Host, authentication_string FROM mysql.user; (Show All users)
Four Ways Of Creating User and Passwords (3rd is Prefered)
$ CREATE USER 'username'@'host' IDENTIFIED WITH authentication_plugin BY 'password';
$ CREATE USER 'username'@'host' IDENTIFIED WITH authentication_string BY 'password';
$ CREATE USER 'sammy'@'localhost' IDENTIFIED BY 'password';
$ CREATE USER 'sammy'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
$ CREATE USER 'sammy'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'password';
Updating User and Password (3rd is Prefered)
$ ALTER USER 'sammy'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
$ ALTER USER 'sammy'@'localhost' IDENTIFIED WITH authentication_string BY 'password';
$ ALTER USER 'root'@'localhost' IDENTIFIED BY '123456789';
$ ALTER USER 'sammy'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Grant Privilages
$ GRANT PRIVILEGE ON database.table TO 'username'@'host';
$ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
$ GRANT ALL PRIVILEGES ON *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
$ FLUSH PRIVILEGES;
===========================================
All Other Commands
$ sudo systemctl status mysql (Check MySQL Server Status)
$ sudo service mysql restart (Restart MySQL Server)
$ sudo systemctl restart mysql.service (Restart MySQL Server)
$ sudo ss -tap | grep mysql (Check Network Status)