我在自学SQL。我已经完成了SQLzoo课程,并希望使用免费的微软测试数据库和MariaDB作为客户端来完成我的工作。我下载了数据库并将其保存在以下路径上:
/usr/bin/northwind_mysql.sql
为了访问数据库,我尝试了以下命令,但是
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'我做错什么了?对于没有SQL经验的人,是否有明确的入门指南?我正在工作中使用它( 2008),但我只是使用简单的读取脚本查询数据库。我想开始学习更多,例如如何开始。
提前谢谢你。
发布于 2013-08-18 15:07:05
我运行了以下步骤并成功连接。
验证连接为 root
mysql -u root -p
mysql> show databases;
mysql> exit;下载Northwind数据库
从这里得到它:http://code.google.com/p/northwindextended/downloads/detail?name=Northwind.MySQL5.sql
将Northwind数据库设置为 root
mysql -u root -p < Northwind.MySQL5.sql添加 gianluca 作为用户,并授予 northwind权限
CREATE USER 'gianluca'@'localhost' IDENTIFIED BY 'whatevs';
GRANT ALL ON northwind.* TO 'gianluca'@'localhost';
FLUSH PRIVILEGES;
exit;连接为 gianluca 和access northwind tables
mysql -u gianluca -p
show databases;
use northwind;
show tables;注意,一旦您在本地主机上创建了用户名,您就不必在连接时指定它。
https://stackoverflow.com/questions/18299663
复制相似问题