← back to the blog
fousa blog
Create a user for your MySQL database
When you want to start to develop a new web application then you'll have to create a new database. In my case I prefer using a MySQL database because it is the same as on my remote server. And I also prefer to create a specific user for each database. And here is how you do that!
CREATE USER
Go to your console and type the following line to log in as root in your mysql command line client.
> mysql -u root -pWhen your root user doesn't have a password you'll have to do it like this:
> mysql -u rootNow you should be logged in as a root user. Next create your user on the MySQL system.
mysql> create user "<username>"@"localhost" identified by "<password>";You don't have to fill in the password. You can also change localhost by "%" to allow access from a remote location on your MySQL databases.
Now give your newly created user some access to your development database.
mysql> grant all privileges on <development_database> .* to "<username>"@"localhost" with grant options;The text between <...> needs to be replaced by whatever you wish!
Send me some feedback!