Create new user msql 8
Here are the steps to create a new user in MySQL 8:
Step 1: Connect to the MySQL server
Open a terminal or command prompt and connect to the MySQL server using the following command:
mysql -u root -p
Replace root
with the root username and password
with the root password.
Step 2: Create a new user
Once connected, use the following command to create a new user:
CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';
Replace newuser
with the desired username and password
with the desired password. The %
symbol allows the user to connect from any host.
Step 3: Grant privileges
Use the following command to grant privileges to the new user:
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'%';
This grants the user all privileges on all databases and tables.
Step 4: Flush privileges
Use the following command to flush the privileges:
FLUSH PRIVILEGES;
This updates the privilege tables to reflect the new user and its privileges.
Step 5: Verify the user
Use the following command to verify that the new user exists and has the correct privileges:
SELECT * FROM mysql.user WHERE User = 'newuser';
This should return a row with the new user's information.
That's it! You have now created a new user in MySQL 8.
Note: Make sure to replace newuser
and password
with the desired values for your new user. Also, be careful when granting privileges, as it can potentially compromise the security of your database.