1、 创建数据库school,字符集为utf8 。
mysql> create database if not exists school default character set utf8;
2、在school数据库中创建Student和Score表,格式如下:
student表:
mysql> create table student( Id int(10) comment'学号' primary key not null unique key auto_increment, Name varchar(20) comment'姓名' not null, Sex varchar(4) comment'性别', Birth year comment'出生年份', Department varchar(20) comment'院系' not null, Address varchar(50) comment'家庭住址');
score表:
mysql> create table score( Id int(10) comment'编号' primary key not null unique key auto_increment, Stu_id int(10) comment'学号' not null,
-> C_name varchar(20) comment'课程名',
-> Grade int(10) comment'分数'
-> );
3、授权用户tom,密码mysql,能够从任何地方登录并管理数据库school。
(1)控制validate_password的验证策略(MySQL5.7版本之后会自动安装validate_password插件,使用户加强密码的强度,0为low(只验证长度),1为medium(长度,大小写和特殊字符),2为strong(长度,大小写,特殊字符和字典文档))。
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=6; -- 最小为4
mysql> alter user user() identified by ‘123456’; -- user() 方法将返回当前用户信息
mysql> show variables like '%validate%';
mysql> create user 'tom'@'%'identified by 'mysql';
mysql> grant all privileges on school to 'tom'@'%';
4、使用mysql客户端登录服务器,重置root密码。
(1)重置root密码(密码忘记时)
[root@localhost ~]# mysqld --user=mysql --skip-grant-tables
[root@localhost my.cnf.d]# mysql – 在另一个会话中直接输入MySQL登录,此时无密码
mysql> flush privileges;刷新权限表,正常来讲输入—skip-grant-tables的会话会恢复正常,不会再卡住
mysql> alter user root@localhost identified by'123ABCabc!';
之后退出重新登陆就好。
本文地址:https://blog.csdn.net/qq_43928088/article/details/107399338
如对本文有疑问, 点击进行留言回复!!
《UnityAPI.Particle粒子》(Yanlz+Unity+SteamVR+云技术+5G+AI+VR云游戏+Particle+lifetime+startColor+立钻哥哥++OK++)
8寸扫码三防军工平板手持终端,双色注塑模/康宁大猩猩玻璃/10点电容屏
信创舆情一线--十五部门印发指导意见进一步促进服务型制造发展
网友评论