1.首先我们需要安装带有可用的mysql5系列社区版资源的rpm包

因为centos自带的仓库是不会自动更新每个软件的最新版本的,所以无法通过yum方式安装mysql的高级版本

  1. rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

2.查询当前可用的mysql安装资源

  1. yum repolist enabled | grep "mysql.*-community.*"

3.安装mysql服务

  1. yum -y install mysql-community-server

4.关闭mysql大小写敏感问题

使用vim编辑器,在/etc/my.sql的[mysqld]节点下加入lower_case_table_names=1配置

  1. # For advice on how to change settings please see
  2. # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
  3. [mysqld]
  4. #
  5. # Remove leading # and set to the amount of RAM for the most important data
  6. # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
  7. # innodb_buffer_pool_size = 128M
  8. #
  9. # Remove leading # to turn on a very important data integrity option: logging
  10. # changes to the binary log between backups.
  11. # log_bin
  12. #
  13. # Remove leading # to set options mainly useful for reporting servers.
  14. # The server defaults are faster for transactions and fast SELECTs.
  15. # Adjust sizes as needed, experiment to find the optimal values.
  16. # join_buffer_size = 128M
  17. # sort_buffer_size = 2M
  18. # read_rnd_buffer_size = 2M
  19. datadir=/var/lib/mysql
  20. socket=/var/lib/mysql/mysql.sock
  21. # 关闭大小写敏感
  22. lower_case_table_names=1
  23. # Disabling symbolic-links is recommended to prevent assorted security risks
  24. symbolic-links=0
  25. # Recommended in standard MySQL setup
  26. sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  27. [mysqld_safe]
  28. log-error=/var/log/mysqld.log
  29. pid-file=/var/run/mysqld/mysqld.pid

5.设置开机启动和启动mysql服务

  1. #加入开机启动
  2. systemctl enable mysqld
  3. #启动mysql服务进程
  4. systemctl start mysqld

6.初始化,执行mysql_secure_installation命令

  1. #会依次出现以下问题。
  2. Set root password? [Y/n]
  3. 是否设置root用户的密码 (y。【设置登录密码】)
  4. Remove anonymous users? [Y/n]
  5. 是否删除匿名用户 (y)
  6. Disallow root login remotely? [Y/n]
  7. 是否禁止root远程登录 (n)
  8. Remove test database and access to it? [Y/n]
  9. 是否删除test数据库(y)
  10. Reload privilege tables now? [Y/n]
  11. 是否重新加载授权信息 (y)

7.开启远程访问

  1. # 登陆mysql
  2. mysql -uroot -p
  3. # 授权(root用户)远程连接权限(不建议)
  4. GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '远程登录密码' WITH GRANT OPTION;
  5. # 刷新权限
  6. FLUSH PRIVILEGES;