当前位置: 首页 >数据库 > MySQL常用命令和常见问题

MySQL常用命令和常见问题

MySQL常用命令和常见问题

--创建数据库并设置字符集create database wip default character set utf8 collate utf8_general_ci;-- 查看字符集变量show variables like 'character%';-- 备份数据库test到文件test.sqlmysqldump -uroot -pmax123 test > test.sql-- 恢复数据库mysql -uroot -pmax123 test < test.sql--注册系统服务,服务名缺省为mysqlmysqld --install [mysql_service_name]--注销系统服务mysqld --remove [mysql_service_name]--测试mysql -uroot -p--查看版本, 注意是大Vmysql -V--环境变量--可以新建一个MySQL的变量,PATH中加%MySQL%,如果有升级或者修改,这是最佳方式--MySQL = C:\Program Files (x86)\mysql-5.6.24\bin--修改密码mysqladmin -u root -p password newpassword

配置默认编码

my.ini中如下修改
MySQL常用命令和常见问题 _ JavaClub全栈架构师技术笔记

windows下删除服务

sc delete mysql[SC] DeleteService 成功,需要重启

或者直接编辑注册表HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services,删除服务后重启电脑

启动服务

net start MySQL

外键
外键必须是parent表的主键/unique 字段,否则添加不成功

--ERROR 1215 (HY000): Cannot add foreign key constraint--类似primary key的设置方式foreign key (user_id) references user (id) on delete cascade--建表后alter tablealter table team_member add constraint fk_team_member_user_id foreign key (user_id) references user (id) on delete cascade;

By the SQL standard, a foreign key must reference either the primary key or a unique key of the parent table. If the primary key has multiple columns, the foreign key must have the same number and order of columns

作者:CooMark
来源链接:https://www.cnblogs.com/wancy86/p/mysql.html

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaclub.cn/database/118486.html

标签:Cannot add
分享给朋友:

“MySQL常用命令和常见问题” 的相关文章

MySQL表的增删改查(进阶) 2022年05月16日 21:54:11
MySQL数据库(基础) 2022年05月16日 21:54:19
MYSQL的存储过程 2022年05月16日 21:54:19
MYSQL查询一个月前的数据 2022年06月12日 09:48:55
Mysql查询用户最后一次登陆时间 2022年06月12日 13:54:22
MySql查询某一天的数据 2022年06月14日 10:43:20