Basic Mysql security settings in CentOS
1. Set or modify the Mysql root Password:
By default, the password is blank after installation. Use the mysqladmin command to set the password:
mysqladmin -uroot password "password"
Mysql command to set the password:
mysql> set password for root@localhost=password('password);
Change Password:
update mysql.user set password=password('password') where user='root';flush privileges;
2. delete default databases and users
drop database test;use mysql;delete from db;delete from user where not(host="localhost" and user="root");flush privileges;
3. Change the default root Account name:
update mysql.user set user="admin" where user="root";flush privileges;
4. Local file security:
set-variable=local-infile=0
5. remote connection to mysql is prohibited. For remote management, use phpmyadmin to edit my. cnf and add it in [mysqld:
skip-networking
6. Minimum permission User:
create database db1;grant select,insert,update,delete,create,drop privileges on database.* to user@localhost identified by 'passwd';
7. Restrict normal users to browse other databases. edit my. cnf and add it in [mysqld:
--skip-show-database
8. quickly fix MySQL Databases
Restore database
mysqlcheck -A -o -r -p
Fix a specified database
mysqlcheck -o -r database -p
9. Select the MySQL configuration file based on the memory size:
my-small.cnf # > my-medium.cnf # 32M - 64Mmy-large.cnf # memory = 512Mmy-huge.cnf # 1G-2Gmy-innodb-heavy-4G.cnf # 4GB