#
# The port the master is listening on.
# optional - defaults to 3306
#master-port = #
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /var/lib/mysql
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
slow_query_log = 1
long_query_time = 10
log-queries-not-using-indexes
log-error=/data/mysql/mysql.err
expire-logs-days = 10
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
六、初始化数据库
注:5.7版本的rpm包安装之后默认不再创建数据库,mysql服务也不会自动启动。但是它还是自动增加了系统用户mysql。
kingtry:~ # mkdir -p /data/mysql/data #创建存放数据文件目录
kingtry:~ # chown -R mysql /data/mysql
kingtry:~ # mysqld --initialize --datadir=/data/mysql/data/ --user=mysql #初始化
初始化成功之后,会将root的默认密码写入文件:/data/mysql/mysql.err 中,如下:
A temporary password is generated for root@localhost: _tVUgaq%P25Q #这就是root的默认密码
七、启动mysql服务即可
kingtry:~ # service mysql start done
Starting MySQL. done
kingtry:~ #
检查MySQL服务是否已经启动:
kingtry:~ # netstat -nat | grep 3306
八、安装后配置之root密码修改
root初始密码自动生成,默认存放在/data/mysql/mysql.err 中。修改root密码的方式有以下两种,随便哪个都行:
1、命令方式
kingtry:~ # mysqladmin -u root -p password 'root123'
Enter password:
2、修改库表数据方式
先登陆mysql服务器
mysql> use mysql
mysql> update user set password=password('root123') where user='root';
mysql> commit;
九、防火墙允许3306端口
kingtry:~ # vi /etc/sysconfig/SuSEfirewall2
在FW_SERVICES_EXT_TCP增加3306端口,如果存在其他端口,则空格隔开,如:
FW_SERVICES_EXT_TCP="21 22 3306"
重启防火墙:
# rcSuSEfirewall2 restart
十、设置远程访问
先登陆mysql服务器,授权root用户可以远程登陆
mysql> grant all PRIVILEGES on *.* to root@'%' identified by 'root123';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
注:生产环境最好只允许root在特定IP的机器上才能远程访问。