首页 > 代码库 > 安装完mysql数据库后的优化(删除多余用户和数据库)
安装完mysql数据库后的优化(删除多余用户和数据库)
1、查看数据库的版本信息:
MariaDB [(none)]> select version(); +----------------+ | version() | +----------------+ | 5.5.52-MariaDB | +----------------+ 1 row in set (0.18 sec)
2、删除多余的账号(除root和localhost的)
MariaDB [(none)]> use mysql MariaDB [mysql]> select user,host from mysql.user; +------+------------------------+ | user | host | +------+------------------------+ | root | 127.0.0.1 | | root | ::1 | | | localhost | | root | localhost | | | lvs-dr01.saltstack.com | | root | lvs-dr01.saltstack.com | +------+------------------------+ 6 rows in set (0.03 sec) MariaDB [mysql]> delete from mysql.user where (user,host) not in (select ‘root‘,‘localhost‘); Query OK, 5 rows affected (0.05 sec) MariaDB [mysql]> select user,host from mysql.user; +------+-----------+ | user | host | +------+-----------+ | root | localhost | +------+-----------+ 1 row in set (0.05 sec)
3、修改mysql默认的mysql管理账号
修改默认的mysql管理账号(root改为mysql,并设置新密码为redhat12345)
MariaDB [mysql]> update mysql.user set user=‘admin‘,password=password(‘redhat12345‘); Query OK, 1 row affected (0.08 sec) Rows matched: 1 Changed: 1 Warnings: 0 MariaDB [mysql]> flush privileges; Query OK, 0 rows affected (0.03 sec) [root@LVS-DR01 ~]# mysql -uadmin -p‘redhat12345‘ MariaDB [(none)]> user mysql; MariaDB [mysql]> show tables;
继续查询:
MariaDB [mysql]> select user,host from mysql.user; +-------+-----------+ | user | host | +-------+-----------+ | admin | localhost | +-------+-----------+ 1 row in set (0.00 sec)
4、删除test数据库:
MariaDB [mysql]> drop database test; MariaDB [mysql]> flush privileges; MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.06 sec)
到此,安装完成后的基本优化已经完成
本文出自 “冰冻vs西瓜” 博客,请务必保留此出处http://molewan.blog.51cto.com/287340/1940496
安装完mysql数据库后的优化(删除多余用户和数据库)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。