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) [[email protected] ~]# 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)
到此,安装完成后的基本优化已经完成
时间: 2024-10-06 21:43:01