无法使用mysql中的数据库(未知数据库) [英] Unable to use database in mysql (unknown database)

查看:55
本文介绍了无法使用mysql中的数据库(未知数据库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开始使用以下 github 包:py-gameday.>

我用 brew mysql 安装了 mysql 并创建了一个 root 密码:

<代码>>mysqladmin -u root 密码 'xxx'

然后我创建了一个用户:

<代码>>mysql -uroot -p输入密码:xxxCREATE USER 'josh'@'localhost' IDENTIFIED BY 'yyy';

以防万一,我再次重置密码:

SET PASSWORD FOR 'josh'@'localhost' = PASSWORD('yyy');

并授予权限:

 GRANT ALL ON gameday.* TO 'josh'@'localhost';

然后我更新了mydb.ini:

[db]用户=乔希密码=yyydb=比赛日

我终于尝试运行以下:

$ mysql -D gameday <游戏日.sql -p输入密码:yyy错误 1049 (42000):未知数据库游戏日"

为什么不起作用?我有一个 gameday.sql 放在目录中.

解决方案

您需要在 mysql 中物理创建数据库.目前 gameday.sql 只是在 mysql 数据库中运行的一组命令,它可能会创建一堆表.

您需要在 mysql 中使用 CREATE DATABASE gameday;,然后授予 josh 写入该数据库的权限.然后mysql -D -p gameday <gameday.sql -p 命令应该可以工作.

I am trying to get started with the following github package: py-gameday.

I installed mysql with brew mysql and created a root password:

> mysqladmin -u root password 'xxx'

I then created a user:

> mysql -uroot -p 
Enter password: xxx
CREATE USER 'josh'@'localhost' IDENTIFIED BY 'yyy';

and just in case, I reset the password again:

SET PASSWORD FOR 'josh'@'localhost' = PASSWORD('yyy');

and grant permissions:

GRANT ALL ON gameday.* TO 'josh'@'localhost';

and I then updated mydb.ini with:

[db]
user=josh
password=yyy
db=gameday

I finally tried running the following:

$ mysql -D gameday < gameday.sql -p
Enter password: yyy
ERROR 1049 (42000): Unknown database 'gameday'

Why doesn't it work? I have a gameday.sql sitting there on the directory.

解决方案

You need to physically create the database in mysql. Currently the gameday.sql is just a set of commands to run in the mysql database which probably creates a bunch of tables.

You'll need to use CREATE DATABASE gameday; in mysql, then give josh permissions to write to that database. Then the mysql -D -p gameday < gameday.sql -p command should work.

这篇关于无法使用mysql中的数据库(未知数据库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆