MySQL Administrator: Essential Commands & Setup
In MySQL, an administrator typically refers to a user with superuser privileges who can perform all database management operations. The administrator can use the following commands to manage the database:
- Logging into MySQL: Administrators can log into MySQL using the following command:
mysql -u username -p
The username is the administrator’s username, and the system will prompt for the password before logging in.
- Creating databases: Administrators can create databases using the following commands.
CREATE DATABASE database_name;
- Delete database: Administrators can use the following command to delete a database:
DROP DATABASE database_name;
- Create user: Administrators can use the following command to create a new user and grant them permissions.
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
- Delete user: Administrators can remove users using the following command:
DROP USER 'username'@'localhost';
- Viewing permissions: Administrators can use the following command to check a user’s permissions:
SHOW GRANTS FOR 'username'@'localhost';
- Change Password: Admins can modify user passwords using the following command:
SET PASSWORD FOR 'username'@'localhost' = PASSWORD('new_password');
These are some common operations used by administrators in MySQL, administrators can use other SQL statements for database management according to specific needs.