my.cnf

因为之前都是在真机安装,与这次阿里云上的部署比起来,还是有点区别的。

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_金沙官网线上,size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

2 安装mysql:

 

yum install mysql mysql-community-server -y

 # 建立慢查询日志文件,如果没有安装时候会报错

touch /var/log/slow.log

#给mysql用户授权这个文件

chown mysql:mysql slow.log

 

 

-------------------------------配置文件------------------------------------------------

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysql]

default-character-set=utf8
socket=/var/lib/mysql/mysql.sock

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 512M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M 
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
#symbolic-links=0
autocommit = 1

slow_query_log = on
slow_query_log_file =/var/log/slow.log
long_query_time = 5

# Recommended in standard MySQL setup
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

 -------------------------------配置文件------------------------------------------------

因为是开发环境,没有压力,所以没进行优化,实际生产时候innodb_buffer_pool_size 参数非常重要,一定要加大到内存70%-80%,之前吃过亏。

 

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

3 报错

[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

进入usr目录

./mysql_install_db --user=mysql

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

5 初次登录设置

mysql_secure_installation

  • Set root password? [Y/n] 
    是否设置root用户的密码
  • Remove anonymous users? [Y/n] 
    是否删除匿名用户
  • Disallow root login remotely? [Y/n] 
    是否禁止root远程登录
  • Remove test database and access to it? [Y/n] 
    是否删除database数据库
  • Reload privilege tables now? [Y/n] 
    是否重新加载授权信息

授权远程用户登录

GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' identified by '密码';

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

Mysql

本文由金沙官网线上发布于数据库,转载请注明出处:my.cnf

您可能还会对下面的文章感兴趣: