54

入门MySQL数据库导入与导出及重置root密码

 5 years ago
source link: https://www.linuxprobe.com/export-databases-password.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
如何导入和导出数据库

要导出数据库,打开终端,确保您未登录MySQL并键入,

mysqldump -u [username] -p [database name] > [database name].sql 

您在命令中选择的数据库现在将导出到您的Droplet。

要导入数据库,首先在MySQL shell中创建一个新的空白数据库作为数据的目标。

CREATE DATABASE newdatabase; 

然后注销MySQL shell,并在命令行中键入以下命令:

mysql -u [username] -p newdatabase With that, your chosen database has been imported into your destination database in MySQL.  
How to Reset a Root Password
When you first install MySQL, you have to set up your root password. However, should you forget it at any point, you can still recover it.  
Step One—Shut Down MySQL
In terminal, stop the MySQL process
 /etc/init.d/mysql stop
Step Two—Access MySQL Safe Mode
In safe mode, you will be able to make changes within the MySQL system with a root password alone, without the need for MySQL root password.
sudo mysqld_safe --skip-grant-tables & Once safe mode has started up, log into MySQL and when prompted, use your standard root password.
mysql -u root mysql
Step Three—Set Up a New Password
Finally, set up the new MySQL root password by typing the command below. Replace "newpassword" with the password of your choice.
update user set password=PASSWORD("newpassword") where User='root'; Be sure to reload everything:
 FLUSH PRIVILEGES; and you now have a new root password.
By Etel Sverdlov

这样,您选择的数据库已导入到MySQL中的目标数据库。

如何重置root密码

当您首次安装MySQL时,您必须设置root密码。但是,如果你忘记它在任何时候,你仍然可以恢复它。

第一步 - 关闭MySQL

在终端中,停止MySQL进程

 /etc/init.d/mysql stop
第二步 - 访问MySQL安全模式

在安全模式下,您将能够在MySQL系统中单独使用root密码进行更改,而无需MySQL root密码。

sudo mysqld_safe --skip-grant-tables & 

一旦安全模式启动,登录MySQL并提示,使用您的标准root密码。

mysql -u root mysql
第三步 - 设置新密码

最后,通过键入以下命令设置新的MySQL root密码。将“newpassword”替换为您选择的密码。

update user set password=PASSWORD("newpassword") where User='root';

一定要重新加载一切:

 FLUSH PRIVILEGES; 

并且您现在有一个新的root密码。


Recommend

  • 60
    • blog.51cto.com 6 years ago
    • Cache

    重置Azure虚拟机登录密码-归零

    如果你“一不小心”忘记了Azure虚拟机的登录密码,怎么办呢?没关系,MicrosoftAzure提供了重置密码的功能,而且直接在Azure门户中就可以操作,很方便。见下图在门户中点击虚拟机,然后选择需要设置的虚拟机,在支持+疑难解答中点击“重置密码”,模式选择重置密码,输...

  • 47

    *本文原创作者:yangyangwithgnu,本文属FreeBuf原创奖励计划,未经许可禁止转载 在逻辑漏洞中,任意用户密码重置最为常见,可能出现在新用户注册页面,也可能是用户登录后重置密码的页面,或者用户忘记密码时的密码找回页面,其...

  • 376
    • www.linuxprobe.com 5 years ago
    • Cache

    mysql数据库导入导出

    1.数据库导入 mysql -uroot -p123456 --default-character-set=utf8 test123< test123.sql 2.数据库导出 导出整个数据库 mysqldump -u...

  • 35
    • database.51cto.com 5 years ago
    • Cache

    如何重置MySQL或MariaDB的Root密码

    几个月前,我在 Ubuntu 18.04 上安装了 LAMP...

  • 51
    • www.linuxidc.com 5 years ago
    • Cache

    如何在MySQL 8中重置root密码

    MySQL中的用户密码存储在用户表中,密码重置实际上是改变该表中记录的值。 要在忘记密码的情况下更改密码,我们的想法是绕过MySQL的身份验证进入系统并使用SQL命令更新记录密码值。 在MySQL 5中,可以使用--skip-grant-tables选...

  • 4

    在日常的数据库维护工作中,经常需要对数据库进行导入导出操作,备份、分析、迁移数据都需要用到导...

  • 4
    • www.cnblogs.com 2 years ago
    • Cache

    navicat~导出数据库密码

    navicat~导出数据库密码 当我们mysql密码忘记了,而在navicat里有记录,我们应该如何导出这...

  • 2
    • longzhiri.github.io 2 years ago
    • Cache

    MySQL导入导出指定列

    MySQL导入导出指定列 09 Feb 2021 | Database ...

  • 2
    • forrestsu.github.io 2 years ago
    • Cache

    MySQL 数据导入导出

    MySQL 数据导入导出 2022年1月22日 | 字数 518 |

  • 6
    • feiju12138.github.io 1 year ago
    • Cache

    【笔记】配置Mysql导入导出操作

    【笔记】配置Mysql导入导出操作 2022-06-06 1...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK