Linux basic configurations - database http://www.basicconfig.com/taxonomy/term/23 en Create new mysql database and new user http://www.basicconfig.com/database/create-new-database-new-user-mysql <!-- google_ad_section_start --><div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"><p>There are two ways to create a new database in mysql. You can use mysql command if you have access to the command line or you can use graphical user interface tools. Here are examples on how to create a new database in mysql using command line and gui tools:</p> <h2>Create a new database using mysql command</h2> <p>1) Login into mysql as root.</p> <table><tr><td><code>root@kkcjlab-server:~# <span style="color:red;">mysql -u root -p</span><br /> Enter password:<br /> Welcome to the MySQL monitor. Commands end with ; or \g.<br /> Your MySQL connection id is 37<br /> Server version: 5.0.75-0ubuntu10.5 (Ubuntu)<br /><br /> Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br /><br /> mysql&gt;<br /></code></td> </tr></table><p>2) Create a new database using mysql 'create database' command.</p> <table><tr><td><code>mysql&gt; <span style="color:red;">create database newdb;</span><br /> Query OK, 1 row affected (0.00 sec)<br /></code></td> </tr></table><p>That's it. Now you have a new database created for root user. If you want to use other user than root to manage the database, then you can create a new user and assign privileges to the database. Here is the steps:</p> <p>1) Login into mysql as root.</p> <p>2) Create user as well as grant privileges.</p> <table><tr><td><code>mysql&gt; <span style="color:red;">GRANT ALL PRIVILEGES ON *.* TO 'drupal'@'localhost' IDENTIFIED BY 'passwd1';<br /> Query OK, 0 rows affected (0.00 sec)</span><br /></code></td> </tr></table><h2>Create a new database using phpmyadmin</h2> <p>You must have PHPMYADMIN installed in your system before performing these steps. Here are steps to create a new database using phpmyadmin:</p> <p>Open web browser. Type <b>localhost/phpmyadmin</b> in the url and press enter.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/2/01-phpmyadmin-create-db.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/2/thumbs/01-phpmyadmin-create-db.png" alt="phpmyadmin enter url image" /></a></p> <p>Login using the database admin user and key in the correct password.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/2/02-phpmyadmin-login.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/2/thumbs/02-phpmyadmin-login.png" alt="phpmyadmin login page image" /></a></p> <p>Create a new database.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/2/03-phpmyadmin-create-newdb.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/2/thumbs/03-phpmyadmin-create-newdb.png" alt="phpmyadmin create new database image" /></a></p> <p>Add new user and assign privileges for the new user to manage database.</p> <p>1) Click <b>Privilege</b> menu.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/2/01-phpmyadmin-create-new-user.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/2/thumbs/01-phpmyadmin-create-new-user.png" alt="phpmyadmin privilege menu image" /></a></p> <p>2) Click <b>Add a new user</b> link to add a new user for mysql database.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/2/02-phpmyadmin-add-new-user.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/2/thumbs/02-phpmyadmin-add-new-user.png" alt="phpmyadmin add new user image" /></a></p> <p>3) Fill login information for a new mysql database user account.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/2/03-phpmyadmin-login-info.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/2/thumbs/03-phpmyadmin-login-info.png" alt="phpmyadmin set mysql new user login information image" /></a></p> <p>4) Set privileges for the new mysql database user.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/2/04-phpmyadmin-global-privileges.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/2/thumbs/04-phpmyadmin-global-privileges.png" alt="phpmyadmin set global privileges image" /></a></p> <p>5) Set specific privileges for the new mysql database user if you want.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/2/06-db-specific-privileges.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/2/thumbs/06-db-specific-privileges.png" alt="phpmyadmin set global privileges image" /></a></p> <p>6) Select specific privileges for the new mysql database user.</p> <p><a href="http://www.basicconfig.com/files/imagepicker/2/07-db-specific-privileges-check-all.png" title="Image" target="_blank"><img src="http://www.basicconfig.com/files/imagepicker/2/thumbs/07-db-specific-privileges-check-all.png" alt="Image" /></a></p> <p>That's all. Now you have a new database and a new user with specific privileges to manage the database.</p> </div></div></div><!-- google_ad_section_end --><div class="field field-name-field-tags field-type-taxonomy-term-reference field-label-above"><div class="field-label">Tags:&nbsp;</div><div class="field-items"><div class="field-item even" rel="dc:subject"><a href="/taxonomy/term/23" typeof="skos:Concept" property="rdfs:label skos:prefLabel" datatype="">database</a></div></div></div> Mon, 19 Jul 2010 03:41:58 +0000 jinlusuh 156 at http://www.basicconfig.com http://www.basicconfig.com/database/create-new-database-new-user-mysql#comments