Gianluca
Gianluca

Reputation: 6657

MariaDB on Linux | Access .sql database

I'm self learning SQL. I've completed the SQLzoo course and wanted to get my hand dirty using a free Microsoft test database and MariaDB as client. I've downloaded the database and saved it on the following path:

/usr/bin/northwind_mysql.sql

To access the database I've tried the following command but

gianluca@gianluca-Aspire-S3-391 ~ $ mysql -u gianluca -p -h localhost northwind_mysql
Enter password: 
ERROR 1044 (42000): Access denied for user 'gianluca'@'localhost' to database 'northwind_mysql'

What I'm doing wrong? Is there any clear Getting Started guide somewhere for people who don't have any experience with SQL? I'm using it at work (MS SQL Server 2008), but I'm only querying the database with simple reading script. I would like to start learning more, for instance how to start it.

Thank you in advance.

Upvotes: 1

Views: 5899

Answers (1)

Stephen O'Flynn
Stephen O'Flynn

Reputation: 2329

I ran the following steps and connected successfully.

Verify connect as root

mysql -u root -p

mysql> show databases;
mysql> exit;

Download the Northwind database

Get it from here: http://code.google.com/p/northwindextended/downloads/detail?name=Northwind.MySQL5.sql

Set up the Northwind database as root

mysql -u root -p < Northwind.MySQL5.sql

Add gianluca as a user and grant permission to northwind

CREATE USER 'gianluca'@'localhost' IDENTIFIED BY 'whatevs';
GRANT ALL ON northwind.* TO 'gianluca'@'localhost';
FLUSH PRIVILEGES;
exit;

Connect as gianluca and access northwind tables

mysql -u gianluca -p
show databases;
use northwind;
show tables;

Notice that once you have created a username on localhost you don't have to specify it when connecting.

Upvotes: 3

Related Questions