Connect to MySQL Server<\/strong><\/h2>\n\n\n\nOpen a terminal or Command Prompt and log in to the MySQL server as a user with administrative privileges. You can use the following command and enter the password when prompted:<\/p>\n\n\n\n
$mysql -u root -p<\/code><\/pre>\n\n\n\nCreate a new MySQL User<\/strong><\/h2>\n\n\n\nOnce you’re logged in to the MySQL server, you can create a new user using the CREATE USER<\/code> statement. Replace new_user<\/code> with the desired username, and password<\/code> with the password you want to set for the user (replace user_password<\/code> with the actual password):<\/p>\n\n\n\nmysql> CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'user_password';<\/code><\/pre>\n\n\n\nThe 'localhost'<\/code> part indicates that this user can only connect from the local machine. If you want the user to be able to connect from any host (not recommended for security reasons), you can use '%'<\/code> instead of 'localhost'<\/code>.<\/p>\n\n\n\nGrant Privileges to the MySQL User<\/strong><\/h2>\n\n\n\nAfter creating the user, you need to grant appropriate privileges to the user for the databases or tables they should access. For example, to grant all privileges on a specific database to the new user, you can use the GRANT<\/code> statement:<\/p>\n\n\n\nmysql> GRANT ALL PRIVILEGES ON your_database_name.* TO 'new_user'@'localhost';<\/code><\/pre>\n\n\n\nReplace your_database_name<\/code> with the name of the database you want to grant access to.<\/p>\n\n\n\nIf you want to grant different sets of privileges or restrict access to specific tables, you can modify the privileges accordingly. For example, to grant only SELECT<\/code> privileges, you can use:<\/p>\n\n\n\nmysql> GRANT SELECT ON your_database_name.your_table_name TO 'new_user'@'localhost';<\/code><\/pre>\n\n\n\nApply Changes and Refresh Privileges<\/strong><\/h2>\n\n\n\nAfter creating the user and granting privileges, apply the changes and refresh MySQL privileges for them to take effect:<\/p>\n\n\n\n
mysql> FLUSH PRIVILEGES;<\/code><\/pre>\n\n\n\nExit the MySQL Client<\/strong><\/h2>\n\n\n\nOnce you have created the user and granted the necessary privileges, you can exit the MySQL client by typing:<\/p>\n\n\n\n
mysql> EXIT;<\/code><\/pre>\n\n\n\nThat’s it! The new user account is now set up in MySQL with the specified privileges. They can use the provided credentials to connect to the MySQL server and access the granted resources. Remember to follow best practices for securing your MySQL server and creating strong passwords for user accounts.<\/p>\n","protected":false},"excerpt":{"rendered":"
To set up a MySQL user account, you’ll need access to the MySQL server with appropriate administrative privileges, such as the root user or an account with CREATE USER and…<\/p>\n","protected":false},"author":1,"featured_media":13265,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,9,16,18],"tags":[180,193,350,393,433,591],"yoast_head":"\n
How to set up a new MySQL User Account<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n