如何导入和导出数据库
mysqldump -u [username] -p [database name] > [database name].sql
登录后复制
要导入数据库,首先在mysql shell中创建一个新的空白数据库作为数据的目标。
CREATE DATABASE newdatabase;
登录后复制
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
登录后复制
如何重置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密码。