Friday, 23 February 2024

Install Mysql

1. Install on Ubuntu

- update server

> sudo apt update
- install mysql server
> sudo apt install mysql-server
- adjust how your root MySQL user authenticates 
> sudo mysql
> mysql >> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
> mysql >> exit
> mysql -u root -p
> ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;
- run the security script with sudo:
> sudo mysql_secure_installation
+ option set password validation 
+ follow to create new password 
2. Creating a User and Granting Privileges 
- access mysql
> sudo mysql -u root -p 
- create user
> mysql >> CREATE USER 'sammy'@'localhost' IDENTIFIED BY 'password';
- create database
> mysql >> CREATE DATABASE test_database; 
mysql >> USE test_database;
- add user and grant privileges
> mysql >> CREATE USER ‘test_database_admin’@’localhost’ IDENTIFIED BY ‘test_password’; 
> mysql >> GRANT ALL PRIVILEGES ON test_database TO ‘test_database_admin’@’localhost’;
 

Thank you 

 

No comments:

Post a Comment

Golang Advanced Interview Q&A