MySQL5.7在CentOS7下安装,配置,调优

1、卸载系统自带的 mariadb-lib
[root@centos-linux ~]# rpm -qa | grep mariadb
 mariadb-libs-5.5.44-2.el7.centos.x86_64 
[root@centos-linux ~]# rpm -e mariadb-libs-5.5.44-2.el7.centos.x86_64 --nodeps

2、下载mysql5.7.16 rpm安装包,官网最新的mysql安装包是mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar下载地址

[root@centos-linux ~]# wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar

然后解压
 [root@linux_node_1 src]# tar -xvf mysql-5.7.16-1.el7.x86_64.rpm-bundle.tar 
  mysql-community-libs-compat-5.7.16-1.el7.x86_64.rpm
  mysql-community-devel-5.7.16-1.el7.x86_64.rpm
  mysql-community-minimal-debuginfo-5.7.16-1.el7.x86_64.rpm
  mysql-community-libs-5.7.16-1.el7.x86_64.rpm
  mysql-community-common-5.7.16-1.el7.x86_64.rpm
  mysql-community-embedded-compat-5.7.16-1.el7.x86_64.rpm
  mysql-community-test-5.7.16-1.el7.x86_64.rpm
  mysql-community-embedded-devel-5.7.16-1.el7.x86_64.rpm
  mysql-community-server-minimal-5.7.16-1.el7.x86_64.rpm
  mysql-community-server-5.7.16-1.el7.x86_64.rpm
  mysql-community-client-5.7.16-1.el7.x86_64.rpm
  mysql-community-embedded-5.7.16-1.el7.x86_64.rpm

3、安装
依次执行(几个包有依赖关系,所以执行有先后)下面命令安装
[root@centos-linux ~]# rpm -ivh mysql-community-common-5.7.16-1.el7.x86_64.rpm 
[root@centos-linux ~]# rpm -ivh mysql-community-libs-5.7.16-1.el7.x86_64.rpm
[root@centos-linux ~]# rpm -ivh mysql-community-client-5.7.16-1.el7.x86_64.rpm 
[root@centos-linux ~]# rpm -ivh mysql-community-server-5.7.16-1.el7.x86_64.rpm

如果在安装rpm -ivh mysql-community-server-5.7.16-1.el7.x86_64.rpm的时候报错如下:
  [root@linux_node_1 src]# rpm -ivh mysql-community-server-5.7.16-1.el7.x86_64.rpm 
  warning: mysql-community-server-5.7.16-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
  error: Failed dependencies:
  libaio.so.1()(64bit) is needed by mysql-community-server-5.7.16-1.el7.x86_64
  libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.16-1.el7.x86_64
  libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.16-1.el7.x86_64
  net-tools is needed by mysql-community-server-5.7.16-1.el7.x86_64

  这个报错的意思是需要安装libaio包和net-tools包:可以yum安装一下,安装 libaio-0.3.107-10.el6.x86_64.rpm,

4、数据库初始化
mysqld --initialize --user=mysql

修改mysql默认端口号3306
vim /etc/my.cnf
[mysqld]
port=3307
max_allowed_packet = 40M
back_log = 510
key_buffer_size = 256M
sort_buffer_size = 6M
read_buffer_size = 4M
join_buffer_size = 8M
max_connections = 768
innodb_buffer_pool_size = 1500M
query_cache_size = 512M 
query_cache_type = 1 


(上面的参数设置末默认值大,可以提高mysql性能。参数查看说明:
缓存命中状态看show status like '%Qcache%'中的:
Qcache_hits:表示有多少次命中缓存。我们主要可以通过该值来验证我们的查询缓存的效果。数字越大,缓存效果越理想。 
查看普通参数用show variables like ,例如:show variables like 'back_log';)

安装rpm包后查看mysql的root的密码

  [root@linux_node_1 src]# cat /var/log/mysqld.log 
  2016-12-07T04:41:58.028558Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  2016-12-07T04:41:58.315188Z 0 [Warning] InnoDB: New log files created, LSN=45790
  2016-12-07T04:41:58.355114Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
  2016-12-07T04:41:58.418448Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7cc98831-bc37-11e6-a263-000c29f902dc.
  2016-12-07T04:41:58.419935Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  2016-12-07T04:41:58.420558Z 1 [Note] A temporary password is generated for root@localhost: )1r3gi,hjgQa
  
现在启动mysql数据库systemctl restart mysqld.service

然后 mysql -uroot -p
这里的密码为上面文件中的密码:)1r3gi,hjgQa

登陆后要修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'csdn@2018';

允许root用户远程登录mysql数据库

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'csdn@2018' WITH GRANT OPTION;

FLUSH PRIVILEGES;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值