#
# 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 [email protected]: _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 [email protected]'%' 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的機器上才能遠端通路。