Setting Up a MySQL User
Our application requires to access the MySQL database. For security reasons, we do not want this user to be the root MySQL user, so we define a user named www-data that has read access to the local databases and can only connect locally with some password.
- First we need to connect to the MySQL monitor using the default password we specified earlier:
1 2 3 4 5 6 7 8 9 |
user@kutayzorlu.com:$ mysql -p --user=root Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.0.45-Debian_1ubuntu3-log Debian etch distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> |
- Then we can create our user and exit the MySQL monitor:
1 2 3 4 5 6 |
mysql> GRANT SELECT ON *.* TO 'www-data'@'localhost' IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye user@JeOS:$ |