生产安装mysql

1.配置yum源
  • vim /etc/yum.repos.d/mysql-community.repo
输入如下内容:
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
2.yum安装
yum list|grep mysql-community
mysql-community-bench.x86_64               5.6.30-2.el6                 mysql56-community
mysql-community-client.i686                5.6.30-2.el6                 mysql56-community
mysql-community-client.x86_64              5.6.30-2.el6                 mysql56-community
mysql-community-common.i686                5.6.30-2.el6                 mysql56-community
mysql-community-common.x86_64              5.6.30-2.el6                 mysql56-community
mysql-community-devel.i686                 5.6.30-2.el6                 mysql56-community
mysql-community-devel.x86_64               5.6.30-2.el6                 mysql56-community
mysql-community-embedded.i686              5.6.30-2.el6                 mysql56-community
mysql-community-embedded.x86_64            5.6.30-2.el6                 mysql56-community
mysql-community-embedded-devel.i686        5.6.30-2.el6                 mysql56-community
mysql-community-embedded-devel.x86_64      5.6.30-2.el6                 mysql56-community
mysql-community-libs.i686                  5.6.30-2.el6                 mysql56-community
mysql-community-libs.x86_64                5.6.30-2.el6                 mysql56-community
mysql-community-libs-compat.i686           5.6.30-2.el6                 mysql56-community
mysql-community-libs-compat.x86_64         5.6.30-2.el6                 mysql56-community
mysql-community-release.noarch             el6-5                        mysql-connectors-community
mysql-community-server.x86_64              5.6.30-2.el6                 mysql56-community
mysql-community-test.x86_64                5.6.30-2.el6                 mysql56-community
yum install mysql-community-libs-compat-5.6.28-2.el6.x86_64
yum install mysql-community-server-5.6.28-2.el6.x86_64
rpm -qa|grep mysql

mysql-community-client-5.6.28-2.el6.x86_64
mysql-community-libs-compat-5.6.28-2.el6.x86_64
mysql-community-libs-5.6.28-2.el6.x86_64
mysql-community-server-5.6.28-2.el6.x86_64
mysql-community-common-5.6.28-2.el6.x86_64
3.启动mysql
service mysqld start
4.设置root密码
/usr/bin/mysqladmin -u root password '××××××'

5.更改超级用户,删除敏感root账户,授权一般用户

  • 查看root权限
        mysql> show grants for 'root'@'localhost';
        +----------------------------------------------------------------------------------------------------------------------------------------+
        | Grants for root@localhost                                                                                                              |
        +----------------------------------------------------------------------------------------------------------------------------------------+
        | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' WITH GRANT OPTION |
        | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION                                                                           |
        +----------------------------------------------------------------------------------------------------------------------------------------+

        2 rows in set (0.00 sec)

  • 授予超级用户和root相同权限
grant all privileges on *.* to '超级用户'@'127.0.0.1' identified by '超级用户密码' with grant option;
grant proxy on ''@'' to '超级用户'@'127.0.0.1' with grant option;
  • 删除其他授权
查看不安全授权:select * from mysql.user where user='root' or user='';
删除授权:delete from mysql.user where user='root' or user='';flush privileges;
再次检查:select * from mysql.user;
  • 授予普通用户增删改查
GRANT SELECT, INSERT, UPDATE, DELETE ON 数据库名.* TO '普通用户'@'127.0.0.1'  IDENTIFIED BY '普通用户密码';
6.上传数据文件,导入数据库

7.更改配置文件


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

[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
# #####################################innodb setting###########################################
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
character_set_server = utf8
back_log=1024
max_connections = 3000
max_connect_errors = 6000
read_buffer_size = 4M
max_allowed_packet=128M
#0:fastest,but most insecure;1:safest,but slowest;2:between 0 and 1
innodb_flush_log_at_trx_commit=1
sync_binlog=1
innodb_support_xa=1
innodb_doublewrite=1
innodb_log_file_size = 200M
innodb_log_files_in_group = 3
#memory*(0.5~0.7)
innodb_buffer_pool_size = 4096M
innodb_log_buffer_size = 64M
query_cache_size = 0
skip_name_resolve
#default timestamp
explicit_defaults_for_timestamp=true
#no lower_case
lower_case_table_names = 1
#init_connect='SET autocommit=0'
innodb_lock_wait_timeout = 50
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Recommended in standard MySQL setup
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
sql_mode=NO_ENGINE_SUBSTITUTION
###################################replication setting#######################################
#replication setting
server-id=1
log-bin=mysql-bin
binlog_format=MIXED
binlog_error_action=ABORT_SERVER
expire_logs_days=7
################################log setting###############################################
#general log
#general_log=1
#general_log_file=/var/log/mysql/mysql-row.log
#slow log
slow_query_log=1
slow_query_log_file=/var/log/mysql/mysql-slow.log
long_query_time=2
#log-queries-not-using-indexes
##########################################################################################

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

8.重启mysql

service mysqld restart

9.设置开机起动
chkconfig mysqld on




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值