mysql+6.9.8.0_mysql系列:centos7.6上安装mysql8.0

centos7.6 上mysql8.0的安装

安装mysql8.0.16版本

安装包可以从mysql官网下载,也可以https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/这里下载

删除原来的数据库

卸载maridb

[root@localhost ~]# rpm -qa|grep mariadb

mariadb-5.5.60-1.el7_5.x86_64

mariadb-server-5.5.60-1.el7_5.x86_64

mariadb-libs-5.5.60-1.el7_5.x86_64

rpm -e --nodeps mariadb-5.5.60-1.el7_5.x86_64

rpm -e --nodeps mariadb-server-5.5.60-1.el7_5.x86_64

查看是否已经安装mysql

[root@localhost ~]# rpm -qa | grep -i mysql

akonadi-mysql-1.9.2-4.el7.x86_64

perl-DBD-MySQL-4.023-6.el7.x86_64

qt-mysql-4.8.7-2.el7.x86_64

[root@localhost ~]# rpm -e --nodeps akonadi-mysql-1.9.2-4.el7.x86_64

[root@localhost ~]# rpm -e --nodeps perl-DBD-MySQL-4.023-6.el7.x86_64

[root@localhost ~]# rpm -e --nodeps qt-mysql-4.8.7-2.el7.x86_64

删除mysql文件

[root@localhost ~]# find / -name mysql

/etc/selinux/targeted/active/modules/100/mysql

/root/.virtualenvs/django_env/lib/python3.6/site-packages/django/contrib/gis/db/backends/mysql

/root/.virtualenvs/django_env/lib/python3.6/site-packages/django/db/backends/mysql

/root/mysql

/var/lib/mysql

/var/lib/mysql/mysql

/usr/lib64/mysql

[root@localhost ~]# rm -rf /val/lib/mysql

[root@localhost ~]# rm -rf /usr/lib/mysql

[root@localhost ~]# rm -rf /usr/lib64/mysql

删除配置文档

rm -rf /etc/my.cnf

再次查找机器是否安装mysql

rpm -qa|grep -i mysql

关闭Selinux

# 临时关闭

setenforce 0

# 永久关闭

vim /etc/sysconfig/selinux

SELINUX=enforcing 改为 SELINUX=disabled

重启服务reboot

安装mysql依赖包(选做)

yum -y install libaio.so.1 libgcc_s.so.1 libstdc++.so.6

yum update libstdc++-4.4.7-4.el6.x86_64

yum search libaio # 检索相关信息

yum install libaio # 安装依赖包

yum install net-tools

第一种安装方式 rpm包

# 安装包

mysql-community-client-8.0.17-1.el7.x86_64.rpm

mysql-community-common-8.0.17-1.el7.x86_64.rpm

mysql-community-libs-8.0.17-1.el7.x86_64.rpm

mysql-community-server-8.0.17-1.el7.x86_64.rpm

# 按照顺序安装

rpm -ivh mysql-community-common-8.0.17-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-8.0.17-1.el7.x86_64.rpm

rpm -ivh mysql-community-client-8.0.17-1.el7.x86_64.rpm

rpm -ivh mysql-community-server-8.0.17-1.el7.x86_64.rpm

可能的报错解决方案

报错1

error: Failed dependencies: /usr/bin/perl is needed by

mysql-community-server-8.0.11-1.el7.x86_64 perl(Getopt::Long) is

needed by mysql-community-server-8.0.11-1.el7.x86_64 perl(strict)

解决1

yum install perl

报错2

error: Failed dependencies:

libaio.so.1()(64bit) is needed by mysql-community-server-8.0.11-1.el7.x86_64

libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-8.0.11-1.el7.x86_64

解决2

wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm

rpm -ivh http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm

初始mysqld –initialize启动数据库

mysqld --initailize --user=mysql

chown mysql:mysql /var/lib/mysql -R

systemctl start mysqld

报错

[root@localhost mysql]# mysqld --initailize

2019-07-28T08:06:16.454284Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.17) starting as process 17757

2019-07-28T08:06:16.457257Z 0 [ERROR] [MY-010123] [Server] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

2019-07-28T08:06:16.457292Z 0 [ERROR] [MY-010119] [Server] Aborting

2019-07-28T08:06:16.457404Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.17) MySQL Community Server - GPL.

# 解决方案

vim /etc/my.cnf

user=mysql

port=3306

mysqld --initailize --user=mysql

systemctl start mysqld.service

2019-07-28T08:08:22.699288Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.17) MySQL Community Server - GPL.

2019-07-28T08:10:21.874694Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.17) starting as process 18083

2019-07-28T08:10:21.884794Z 1 [ERROR] [MY-012592] [InnoDB] Operating system error number 13 in a file operation.

2019-07-28T08:10:21.884807Z 1 [ERROR] [MY-012595] [InnoDB] The error means mysqld does not have the access rights to the directory.

2019-07-28T08:10:21.884818Z 1 [ERROR] [MY-012270] [InnoDB] os_file_get_status() failed on './ibdata1'. Can't determine file permissions

2019-07-28T08:10:21.884830Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine

2019-07-28T08:10:21.885164Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.

2019-07-28T08:10:21.885227Z 0 [ERROR] [MY-010119] [Server] Aborting

# 解决

ll /var/run/mysqld/

# 不存在

mkdir -p /var/run/mysqld/

chown -R mysql:mysql /var/run/mysqld

# 如果还报错,则进入下一步。

# 关闭selinux.并重启。

setenforce 0

# 重启服务

service mysqld restart

systemctl status mysqld.service

开机启动服务设置

systemctl enable mysqld

查看初始化密码

# 命令查看数据库的密码

cat /var/log/mysqld.log | grep password

第二种mysql安装方式(建议使用这一种)

userdel mysql

# 增加mysql用户组,用户

groupadd mysql

useradd -g mysql mysql

tar xf mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz

mv mysql-8.0.17-linux-glibc2.12-x86_64 /usr/local/mysql

cd /usr/local/mysql

mkdir data sql_log undo_log

chown mysql:mysql -R data/ sql_log/ undo_log/

vim /etc/profile

export PATH=$PATH:/usr/localmysql/bin

source /etc/profile

# 拷贝my.cnf的下方内容

vim /etc/my.cnf

:%s@/home/mysql@/usr/local/mysql@

# 初始化

mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

# 拷贝启动程序

cd /usr/local/mysql/support-files

cp mysql.server /etc/init.d/mysqld

# 启动服务

/etc/init.d/mysqld start

# 报错

Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data//localhost.localdomain.pid).

检查my.cnf中路径配置是否有误前面创建的三个文件夹是否一致,文件夹用户组是否属于mysql

# 查询密码:

[root@localhost sql_log]# grep password mysql-error.log

2019-07-28T10:50:16.286737Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: du%3pH5VBo;l

# 登录mysql

mysql -uroot -p

# 可以看到版本号为8.0.17

[root@localhost sql_log]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 9

Server version: 8.0.17

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

# 修改密码

alter user user() identified by '123456';

my.cnf配置文件

[client]

port=3306

socket=/usr/local/mysql/data/mysql.sock

[mysqld]

# Skip #

skip_name_resolve= 1

skip-external-locking=1

symbolic-links= 0

# GENERAL #

user = mysql

default_storage_engine=InnoDB

character-set-server=utf8

socket=/usr/local/mysql/data/mysql.sock

pid_file=/usr/local/mysql/data/mysqld.pid

basedir = /usr/local/mysql

#log_error=/usr/local/mysql/sql_log/mysql_1302.err

port=3306

bind-address=0.0.0.0

explicit_defaults_for_timestamp=off

#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

sql_mode=NO_ENGINE_SUBSTITUTION

#read_only=on

# MyISAM #

key_buffer_size=32M

#myisam_recover=FORCE,BACKUP

# undo log #

innodb_undo_directory=/usr/local/mysql/undo_log

innodb_undo_tablespaces=16

# SAFETY #

max_allowed_packet=100M

max_connect_errors=1000000

sysdate_is_now=1

#innodb= FORCE

#innodb_strict_mode=1

secure-file-priv=/usr/local/mysql/sql_log

default_authentication_plugin='mysql_native_password'

# Replice #

server-id=1306

relay_log=mysqld-relay-bin

gtid_mode=on

enforce-gtid-consistency

log-slave-updates=on

master_info_repository=TABLE

relay_log_info_repository=TABLE

# group replication specific options

#plugin-load=group_replication.so

#group_replication=FORCE_PLUS_PERMANENT

#transaction-write-set-extraction=XXHASH64

#loose-group_replication_start_on_boot=ON

#loose-group_replication_bootstrap_group=OFF

#loose-group_replication_group_name='aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'

#group_replication_local_address='10.102.13.2:33061'

#group_replication_group_seeds='10.102.13.3:33061,10.102.13.5:33061'

# DATA STORAGE #

datadir=/usr/local/mysql/data/

tmpdir=/tmp

# BINARY LOGGING #

log_bin=/usr/local/mysql/sql_log/mysql-bin

max_binlog_size=1000M

binlog_format=row

expire_logs_days=7

# sync_binlog=1

# CACHES AND LIMITS #

tmp_table_size = 32M

max_heap_table_size = 32M

max_connections = 4000

thread_cache_size = 2048

open_files_limit = 65535

table_definition_cache = 4096

table_open_cache = 4096

sort_buffer_size = 2M

read_buffer_size = 2M

read_rnd_buffer_size = 2M

# thread_concurrency = 24

join_buffer_size = 1M

# table_cache = 32768

thread_stack = 512k

max_length_for_sort_data = 16k

# INNODB #

innodb_flush_method = O_DIRECT

innodb_log_buffer_size = 16M

innodb_flush_log_at_trx_commit = 2

innodb_file_per_table = 1

innodb_buffer_pool_size = 2G

#innodb_buffer_pool_instances = 8

innodb_stats_on_metadata = off

innodb_open_files = 8192

innodb_read_io_threads = 16

innodb_write_io_threads = 16

innodb_io_capacity = 20000

innodb_thread_concurrency = 0

innodb_lock_wait_timeout = 60

innodb_old_blocks_time=1000

innodb_use_native_aio = 1

innodb_purge_threads=1

innodb_change_buffering=all

innodb_log_file_size = 128M

innodb_log_files_in_group = 3

innodb_data_file_path = ibdata1:1024M:autoextend

innodb_rollback_on_timeout=on

# LOGGING #

log_error=/usr/local/mysql/sql_log/mysql-error.log

# log_queries_not_using_indexes = 1

# slow_query_log = 1

slow_query_log_file=/usr/local/mysql/sql_log/slowlog_1305.log

# TimeOut #

#interactive_timeout = 30

#wait_timeout = 30

#net_read_timeout = 60

[mysqldump]

quick

max_allowed_packet = 100M

[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates

[myisamchk]

key_buffer_size = 256M

sort_buffer_size = 256M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值