1. 更改默认端口(默认3306)mysql
能够从必定程度上防止端口扫描工具的扫描sql
2. 删除掉test数据库数据库
drop database test;
3. 密码改的复杂些ide
# 1 set password for root@localhost=password('test'); # 2 use mysql; update user set password=password('test') where user='root'; flush privileges;
4. 删除默认的用户工具
use mysql; delete from db; delete from user where not(host="localhost" and user="root"); flush privileges;
5. 改变默认mysql管理员的名称spa
use mysql; update user set user="admin" where user="root"; flush privileges;
6. 禁止远程链接mysql
a. 设置账号不容许从远程登录,只能在localhostcode
use mysql; update user set host = '%' where user = 'admin'; select host, user from user;
b. 受权某个特定的用户能够从远程登陆mysql
(1) 设定任务主机,均可以根据某个用户名|密码,登陆mysql服务的全部数据库blog
grant all privileges on *.* to 'myuser'@'%' identified by 'mypassword' with grant option; flush privileges;
(2) 设定特定IP的主机,根据某个用户名|密码,登陆mysql服务的全部数据库it
grant all privileges on *.* to 'myuser'@'192.168.1.3' identified by 'mypassword' with grant option; flush privileges;
(3) 设定特定IP的主机,根据用某个户名|密码,登陆指定的数据库(dk--数据库名)io
grant all privileges on dk.* to 'myuser'@'192.168.1.3' identified by 'mypassword' with grant option; flush privileges;