MySQL- MySQL is an open-source database management system, commonly installed as part of the popular LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. It uses a relational database and SQL (Structured Query Language) to manage its data.
Prerequisites-
Step 1- Access MySQL Shell:
Log on to MySQL shell with the user have super privilege and run the following command to create a new database. Windows user can open MySQL shell by searching "MySQL Client" on the Windows search.
Access MySQL shell: To access MySQL shell from the local server using this command. If you are trying to access MySQL server from the remote machine then please use hostname also.
1 A- Access MySQL Shell local server
Step 2- Create a database- To create a new database, Use the following command.
Where:
Create database = is a command.
Linux = is database name.
Step 3- Create a User: To create a new user, Use the following command.
Step 4- Grant Permission- To grant user permission on a database follow the command below.
4A- Grant Database access from localhost only-
4B- To Grant Database access from the remote host.
Step 5- Reload privileges- To reload user privileges use the following command.
Step 6- List database, user and host- To get the list of database, User and host use the below command.
Step 7- Drop database-
To drop database use the following command.
Step 8- Drop User-
To drop User follow the below command. If you want to delete a user with localhost then it should be "@localhost" for Remote host address use "@remotehost_IP"
!!Cheers!!
Prerequisites-
- Linux Machine or Windows machine with Install MySQL server.
- MySQL access with super privileges.
Step 1- Access MySQL Shell:
Log on to MySQL shell with the user have super privilege and run the following command to create a new database. Windows user can open MySQL shell by searching "MySQL Client" on the Windows search.
Access MySQL shell: To access MySQL shell from the local server using this command. If you are trying to access MySQL server from the remote machine then please use hostname also.
1 A- Access MySQL Shell local server
$ mysql -u root -p1 B- Access MySQL shell from Remote machine.
$ mysql -u root -p -h 192.168.102.10
Step 2- Create a database- To create a new database, Use the following command.
mysql> create database Linux;
Create database = is a command.
Linux = is database name.
Step 3- Create a User: To create a new user, Use the following command.
mysql> create user amar@'localhost' identified by 'mypassword';
4A- Grant Database access from localhost only-
mysql> grant all privileges on Linux.* To amar@'localhost' identified by 'mypassword';
4B- To Grant Database access from the remote host.
mysql> grant all privileges on Linux.* To amar@'192.168.102.12' identified by 'mypassword';
mysql> FLUSH PRIVILEGES;
mysql> select db,host,user from mysql.db;
To drop database use the following command.
mysql> drop database database_Name;
To drop User follow the below command. If you want to delete a user with localhost then it should be "@localhost" for Remote host address use "@remotehost_IP"
mysql> drop user User_Name@'Host_Name';
To Remove user with localhost
To Remove user With remote host address
!!Cheers!!
Thanks for the clear guide on creating a MySQL database, user, and granting permissions! It’s essential for database management. Check out Better Joy for more database tutorials!
ReplyDelete