mysql - 使用 SSH 在 CentOS 上恢复 MYSQL 数据库时遇到问题
问题描述
我只需要更改 Godaddy 的 [专用 CentO] 服务器。
使用 FTP 将数据库备份文件上传.sql
到站点后,我使用 SSH 连接到我的站点。
使用 su - 命令更改为超级用户后,我尝试使用以下代码恢复我的数据库:
[root@sXXX.XXX.XXX.XXX ~]# mysql -u alaskasl_destiny -p alaskasl_freakout < /home/alaskasl/backup/databases/alaskasl_freakout.sql
我得到以下ERROR 1044 (42000): Access denied for user 'alaskasl_destiny'@'localhost' to database 'alaskasl_freakout'
我无法弄清楚我做错了什么。这个命令过去一直对我有用
解决方案
First and foremost, if alasas1... is your real username, I would replace it with 'username'. Never give that info out, especially on a public place like Stackoverflow.
That said, a few things to check 1. You need to know the root user's login credentials for this new mysql instance. If this is a new setup the user is root with no password, so you should be able to use the following command:
$ mysql -u root
Once you do get in to mysql, you will see a prompt similar to: mysql> at that prompt you can type
mysql> show databases;
and a list of databases will display. Does the database you expect to be in there in there?
if not, here is what you need to do:
mysql> CREATE DATABASE 'database_name';
mysql> CREATE USER 'username' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON *.database_name TO 'username';
mysql> exit
At this point what you did was create the database, create a user with a password in mysql, and granted access to that database for that user. Once you type exit, you should now be back at the command prompt.
Now you can run mysql -u username -p database_name < /path/to/sql_file.sql
推荐阅读
- facebook-graph-api - 为什么 Facebook 登录在模拟器和实体手机之间的行为不同
- python - 熊猫列过滤器慢
- javascript - 如何使用带有 if 条件的 JavaScript 更改背景图像?
- python - 具有多个列表和条件的排列
- python - 纹理图像匹配的算法建议
- python - python中的单个var赋值和多个var赋值之间有什么不同的行为吗?
- c++ - 我的 KMP 算法有问题吗?
- go - “无法评估类型界面中的字段键”访问 Go 模板中的键
- swagger - Micronaut openAPI Swagger 不生成视图
- postgresql - Postgresql 10 无法插入到具有身份主键的表中