Step 1 — Installing MySQL
To install it, update the package index on your server if you’ve not done so recently:
$sudo apt update
Then install the mysql-server package:
$ sudo apt install mysql-server
Ensure that the server is running using the systemctl start command:
$ sudo systemctl start mysql.service
$ mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'Rajesh$123sa332';
mysql> exit
Step 2 — Configuring MySQL – NOT WORKING WITH LATEST
For fresh installations of MySQL, you’ll want to run the DBMS’s included security script. This script changes some of the less secure default options for things like remote root logins and sample users.
Run the security script with sudo:
$ sudo mysql_secure_installation
Step 3 — Creating a Dedicated MySQL User and Granting Privileges
$ mysql -u root -p
$ CREATE USER 'sammy'@'localhost' IDENTIFIED BY 'DevOpsSchool$123';
$ GRANT ALL PRIVILEGES ON *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
$ FLUSH PRIVILEGES;
$ exit
$ mysql -u sammy -p
# OPTIONAL Only for Reference
$ CREATE USER 'sammy'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
$ ALTER USER 'sammy'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
$ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
Latest posts by Rajesh Kumar (see all)
- Top 10 Website Development Companies in Vadodara - December 20, 2024
- Compare SAST, DAST and RASP & its Tools for DevSecOps - December 19, 2024
- Comparing AWS, Azure, and Google Cloud in terms of services - December 19, 2024