카테고리 없음

how to add 'user' in mysql . and why 'root' is default?

청어와물메기 2023. 2. 9. 00:00
728x90

To add a new user in MySQL, you can use the CREATE USER statement followed by the GRANT statement.

Here's an example of how to create a new user named "newuser" with the password "newpassword":

 
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'newpassword';

Once the user is created, you can grant them privileges using the GRANT statement. For example, to grant the SELECT, INSERT, and UPDATE privileges on a database named "testdb" to the new user, you can use the following command:

 
GRANT SELECT, INSERT, UPDATE ON testdb.* TO 'newuser'@'localhost';

Regarding the "root" user, it is the default administrative user in MySQL. The root user is created during the installation of MySQL and has the highest level of privileges, allowing it to perform any operation on the MySQL server, including creating and modifying users, granting and revoking privileges, and managing databases. The root user is usually created with a password, and you can log in to the MySQL server as the root user by specifying the username and password in the mysql client.

 

728x90