Enter current password forroot(enter for none): #初次运行直接回车
Set root password? [Y/n]#是否设置root用户密码,输入y并回车或直接回车
New password: #设置root用户的密码
Re-enter new password: #再输入一次你设置的密码
Remove anonymous users? [Y/n]#是否删除匿名用户
Disallow root login remotely? [Y/n]#是否禁止root远程登录
Remove test database and access to it? [Y/n]#是否删除test数据库
Reload privilege tables now? [Y/n]#是否重新加载权限表
#其他设置
mysql #进入mysql
#创建用户命令
mysql>create user 'username'@'localhost' identified by 'password';
#直接创建用户并授权的命令
mysql>grant all on *.* to 'username'@'localhost' indentified by 'password';
#授予外网登陆权限
mysql>grant all privileges on *.* to 'username'@'%' identified by 'password';
#授予权限并且可以授权
mysql>grant all privileges on *.* to 'username'@'hostname' identified by 'password' with grant option;
mysql> show variables like "%character%"; #MariaDB查看字符集
mysql>show variables like "%collation%"; #MariaDB查看字符集
mysql_secure_installation #执行此命令
#按提示根据实际情况进行设置
Enter current password for root (enter for none): #初次运行直接回车
Set root password? [Y/n] #是否设置root用户密码,输入y并回车或直接回车
New password: #设置root用户的密码
Re-enter new password: #再输入一次你设置的密码
Remove anonymous users? [Y/n] #是否删除匿名用户
Disallow root login remotely? [Y/n] #是否禁止root远程登录
Remove test database and access to it? [Y/n] #是否删除test数据库
Reload privilege tables now? [Y/n] #是否重新加载权限表
#其他设置
mysql #进入mysql
#创建用户命令
mysql>create user 'username'@'localhost' identified by 'password';
#直接创建用户并授权的命令
mysql>grant all on *.* to 'username'@'localhost' indentified by 'password';
#授予外网登陆权限
mysql>grant all privileges on *.* to 'username'@'%' identified by 'password';
#授予权限并且可以授权
mysql>grant all privileges on *.* to 'username'@'hostname' identified by 'password' with grant option;
mysql> show variables like "%character%"; #MariaDB查看字符集
mysql>show variables like "%collation%"; #MariaDB查看字符集
mysql_secure_installation #执行此命令
#按提示根据实际情况进行设置
Enter current password for root (enter for none): #初次运行直接回车
Set root password? [Y/n] #是否设置root用户密码,输入y并回车或直接回车
New password: #设置root用户的密码
Re-enter new password: #再输入一次你设置的密码
Remove anonymous users? [Y/n] #是否删除匿名用户
Disallow root login remotely? [Y/n] #是否禁止root远程登录
Remove test database and access to it? [Y/n] #是否删除test数据库
Reload privilege tables now? [Y/n] #是否重新加载权限表
#其他设置
mysql #进入mysql
#创建用户命令
mysql>create user 'username'@'localhost' identified by 'password';
#直接创建用户并授权的命令
mysql>grant all on *.* to 'username'@'localhost' indentified by 'password';
#授予外网登陆权限
mysql>grant all privileges on *.* to 'username'@'%' identified by 'password';
#授予权限并且可以授权
mysql>grant all privileges on *.* to 'username'@'hostname' identified by 'password' with grant option;
mysql> show variables like "%character%"; #MariaDB查看字符集
mysql>show variables like "%collation%"; #MariaDB查看字符集