Home  • Database • MySQL

Create mysql user with specified database of all privileges

MySQL For the latest version
create database if not exists wdpf_40_alam;
drop user if exists alam@localhost;
flush privileges;
create user alam@localhost identified with mysql_native_password by 'alam@123';
GRANT ALL ON wdpf_40_alam.* TO alam@localhost;
flush privileges;

For old version
create database if not exists wdpf36_rowdra;

#-- domain based user access privilege
drop user if exists rowdra@localhost;
flush privileges;
create user rowdra@localhost identified by 'rowdra@123';
GRANT ALL ON wdpf36_rowdra.* TO rowdra@localhost;
flush privileges;

#-- IP based user access privilege-----
drop user if exists rowdra@27.147.169.237;
flush privileges;
create user rowdra@27.147.169.237 identified by 'rowdra@123';
GRANT ALL ON wdpf36_rowdra.* TO rowdra@27.147.169.237;
flush privileges;
To change password for any user (version 8.0+):
set password for 'userName'@'localhost' = 'new_password';
Old Version
 ALTER USER 'username'@'localhost' IDENTIFIED BY 'MyNewPass';
To change current user password:
select current_user();
set password = 'new_password';

Comments 0


Copyright © 2024. Powered by Intellect Software Ltd