mysql相关命令及安全配置
1. 为mysql的root用户设置密码
[root@web01 mysql]# mysqladmin -u root password '123456' #设置root登录密码[root@web01 mysql]# mysql -uroot -p #登录命令[root@web01 mysql]# mysql -uroot -p123456 #带密码登录
2.清理无用的mysql用户及库
mysql> select user,host from mysql.user; #查看所有用户+------+-----------+| user | host |+------+-----------+| root | 127.0.0.1 || root | ::1 || root | localhost |+------+-----------+6 rows in set (0.00 sec)mysql> drop user "root"@"web01"; #删除无用的用户Query OK, 0 rows affected (0.00 sec)若遇到无法删除的用户则用如下命令:mysql> delete from mysql.user where user='root' and host='web01';
mysql> select user,host from mysql.user; #最后保留的用户+------+-----------+| user | host |+------+-----------+| root | 127.0.0.1 || root | localhost |+------+-----------+2 rows in set (0.00 sec)mysql> drop database test; #删除无用的数据库文件Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges; #刷新权限Query OK, 0 rows affected (0.00 sec)