最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Mac本地给mysql数据库改名

Mac crifan 2237浏览 0评论

折腾

【已解决】Antd Pro中翻页出错:发出的请求针对的是不存在的记录

期间,需要去备份在线mysql,恢复导入到Mac本地的mysql

但是同时保留Mac本地之前的mysql的数据库,用于对比查找问题

所以需要去:

mysql 数据库 改名

MySQL数据库改名的三种方法 – yayun – 博客园

MySQL中数据库重命名 – CSDN博客

mysql database rename

How do I quickly rename a MySQL database (change schema name)? – Stack Overflow

How do I change the database name using MySQL? – Stack Overflow

MySQL 数据库重命名 – Jamin Zhang

感觉此处还是用mysqldump比较省事。

去看看:

mysqldump -R old_db | mysql new_db

【总结】

此处Mac中本地mysql去改名,最简单的还是:

mysqldump -u username -p -v olddatabase > olddbdump.sql
mysqladmin -u username -p create newdatabase
mysql -u username -p newdatabase < olddbdump.sql

详细过程:

➜  mysql_backup_restore mysqldump -uroot -pcrifan_mysql -v naturling > local_mysql_naturling.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
-- Connecting to localhost...
-- Retrieving table structure for table auth_group...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table auth_group_permissions...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table auth_permission...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table django_admin_log...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table django_content_type...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table django_migrations...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table django_session...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table django_site...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table enum_value_dict...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table keyword...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table keyword_rel...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table media...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table media_keyword_rel...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table media_scene_rel...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table qa...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table qa_keyword_rel...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table qa_scene_rel...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table scene...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table scene_keyword_rel...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table script_dialog...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table script_history...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table script_review...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table script_script...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table thesaurus...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table user_functiongroup...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table user_functiongroup_members...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table user_user...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table user_user_groups...
-- Sending SELECT query...
-- Retrieving rows...
-- Retrieving table structure for table user_user_user_permissions...
-- Sending SELECT query...
-- Retrieving rows...
-- Disconnecting from localhost...
➜  mysql_backup_restore ll
total 67624
-rw-r--r--  1 crifan  staff    33M  7 25 10:07 local_mysql_naturling.sql
➜  mysql_backup_restore mv local_mysql_naturling.sql local_mysql_naturling_180725.sql
➜  mysql_backup_restore ll
total 67624
-rw-r--r--  1 crifan  staff    33M  7 25 10:07 local_mysql_naturling_180725.sql
➜  mysql_backup_restore mysqladmin -uroot -pcrifan_mysql create naturling_local
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
➜  mysql_backup_restore mysql -uroot -pcrifan_mysql naturling_local < local_mysql_naturling_180725.sql
mysql: [Warning] Using a password on the command line interface can be insecure.

即可。

转载请注明:在路上 » 【已解决】Mac本地给mysql数据库改名

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.205 seconds, using 22.09MB memory