Manage MySql users
- Create user
CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';
- Grant privileges
-- Grant all privileges including the grant option (basically an additional root user) GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'%' WITH GRANT OPTION; -- Grant all privileges GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'%'; -- Grant read-only privileges GRANT SELECT ON *.* TO 'newuser'@'%';
- Flush privileges
FLUSH PRIVILEGES;
- Change password
SET PASSWORD FOR 'user'@'localhost' = 'NewPassword';
If MySql server is accessible from network, limit users access from local lan by using 10.0.0.% instead of just %, or enter a specific IP address
ALTER USER 'username'@'ip_address' IDENTIFIED WITH mysql_native_password BY 'password';