Mysql: Difference between revisions

From Network Security Wiki
Content added Content deleted
Line 30: Line 30:


Connecting to a database directly:
Connecting to a database directly:
mysql testdb -u user -pmypassword
mysql testdb -u guest -pguest123


= Access Control =
= Access Control =

Revision as of 00:26, 28 July 2017

Installation

For Ubuntu:

sudo apt-get install mysql-server

Login as root

mysqladmin -u root -p

Creating Databases

Create a Database:

mysqladmin -u root -p create testdb

Check Databases:

mysql -u root -p
show databases;

Select a Database and check its tables:

use testdb;
show tables;

Checking Table contents:

show columns from column_name;


User Administration

Creating a user:

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON testdb.* TO 'guest'@'localhost' IDENTIFIED BY 'guest123';

Connecting to a database directly:

mysql testdb -u guest -pguest123

Access Control

Granting access to the Database:

        This section is under construction.

Dumping Databases

Export DB

mysqldump testdb > testdb.sql -p

Import DB

mysql testdb < /var/www/html/test.com/testdb.sql -p

External Connections

The default port of the database server is 3306 If you are unable to connect to the database, try disabling the IPTables:

iptables -F