修改配置文件
bind-address = 10.6.20.1 port = 3306 character_set_server = utf8 max_connect_errors = 1000000 max_connections = 500 datadir = /data/mysql log-error = /var/log/mysql/mysql-error.log-error skip_name_resolve back_log = 2000 log-bin = /data/mysql binlog-format = MIXED expire_logs_days = 2
bind-address:监听的IP地址
max_connect_errors:最大允许错误次数(注:是访问协议错误,若某个IP错误次数达到该阈值,则被屏蔽)
max_connections :最大连接数(能同时访问server的连接个数,若达到该阈值,则不能再连接到server)
skip_name_resolve :跳过域名反解
back_log :创建TCP连接时,允许的最大同时未完成的连接个数
expire_logs_days :binlog的保留天数
注:
datadir和log-error和log-bin等对应目录需要确保已创建,并且权限为mysql所有。
例如:
mkdir -p /data/mysql
chown -R mysql.mysql /data/mysql
mkdir -p /var/log/mysql
chown -R mysql.mysql /var/log/mysql
配置完成后,启动mysql:
/etc/init.d/mysqld start
mysql> SELECT user,host FROM MYSQL.USER; +------+-----------+ | user | host | +------+-----------+ | root | 127.0.0.1 | | root | ::1 | | | localhost | | root | localhost | +------+-----------+ 4 rows in set (0.00 sec) mysql> DROP USER ''@localhost; Query OK, 0 rows affected (0.25 sec) mysql> DROP USER 'root'@'::1'; Query OK, 0 rows affected (0.00 sec) mysql> SELECT user,host FROM MYSQL.USER; +------+-----------+ | user | host | +------+-----------+ | root | 127.0.0.1 | | root | localhost | +------+-----------+ 2 rows in set (0.00 sec)
为root用户赋予密码:
mysql> UPDATE mysql.user SET password = PASSWORD('newpassword') WHERE user = 'root'; Query OK, 0 rows affected (0.00 sec) Rows matched: 3 Changed: 0 Warnings: 0 mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye