Answers for "how to create sql user"

SQL
3

sql create user

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
# Some PHP versions may have issues with the above statement
# use the older mysql_native_password plugin instead:
CREATE USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
# Give access to all databases with all privileges like root user
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;
# Give access to SPECIFIC database with all privileges
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';
# when done, flush privileges.
FLUSH PRIVILEGES;
Posted by: Guest on October-19-2021
1

create user sql

-- Creates the login AbolrousHazem with password '340$Uuxwp7Mcxo7Khy'.  
CREATE LOGIN username   
    WITH PASSWORD = 'password';  
GO  

-- Creates a database user for the login created above.  
CREATE USER AbolrousHazem FOR LOGIN AbolrousHazem;  
GO
Posted by: Guest on July-14-2020
0

how to create sql user

-- Step 1: Create a new user with a secure password
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'strong_password';

-- Step 2: Grant specific privileges to the user for a specific database
GRANT ALL PRIVILEGES ON database_name.* TO 'new_user'@'localhost';

-- Step 3: Alternatively, grant all privileges on all databases (admin-level access)
GRANT ALL PRIVILEGES ON *.* TO 'new_user'@'localhost' WITH GRANT OPTION;

-- Step 4: Apply the changes immediately
FLUSH PRIVILEGES;

-- Step 5 (Optional): Test the new user login
-- Exit your current MySQL session and log in as the new user:
-- mysql -u new_user -p
Posted by: Ritik Raj on November-30-2024

Code answers related to "SQL"

Browse Popular Code Answers by Language