Home Apache PHP Ubuntu MySQL Linux HTML Win CSS Perl Javascript Rants Retro
 
Print This Page
Date Posted: Sunday 07th of February 2010 | Category: MySQL
Create a new database in MySQL, User and set permissions
Create a new database in MySQL, Create user & Set permission, Change user password
To create a new database on MySQL you first need to login as root via the terminal. In the terminal enter the following command:

mysql -u root -p

You will then be prompted for the root password. Since this is a default install I just pressed enter which takes to the MySQL prompt.

mysql>

We shall now create a new database. After the prompt enter the following command:

mysql> create database test;

We shall now create a new user named gnulinux and give the following permissions on database test

mysql> grant CREATE,INSERT,DELETE,UPDATE,SELECT on test.* to gnulinux@localhost;

Or why not grant ALL PRIVILEGES

mysql> grant ALL PRIVILEGEST on test.* to gnulinux@localhost;

We shall now create a new password for user gnulinux:

mysql> set password for gnulinux@localhost = password('NEWPASSWORD');

Lets see the user gnulinux is the main MySQL table

mysql> SELECT * from

Lets now delete the database and the user gnulinux

mysql> drop database test;

mysql> DELETE FROM WHERE user='gnulinux';

mysql> FLUSH PRIVILEGES;

So we created a new database and new user. We gave the new user permissions to use the database. We then deleted the database and then the user.