日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

centos mysql rpm re_centos7和centos6.5环境rpm方式安装mysql5.7和mysql5.6详解

發布時間:2024/9/27 数据库 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 centos mysql rpm re_centos7和centos6.5环境rpm方式安装mysql5.7和mysql5.6详解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

centos環境安裝mysql5.7

其實不建議安裝mysql5.7 語法和配置可能和以前的版本區別較大,多坑,慎入

1.yum方式安裝(不推薦)

a.安裝mysql5.7 yum源

centos6:

wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm

yum localinstall mysql-community-release-el6-5.noarch.rpm

centos7:

wget dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

yum localinstall mysql57-community-release-el7-7.noarch.rpm

yum方式安裝:

yum install mysql-community-server

2.rpm方式安裝(推薦)

因yum源是在國外下載速度非常慢,建議直接下載后通過本地安裝

centos6:

mysql-community-client-5.7.15-1.el6.x86_64.rpm

mysql-community-common-5.7.15-1.el6.x86_64.rpm

mysql-community-libs-5.7.15-1.el6.x86_64.rpm

mysql-community-server-5.7.15-1.el6.x86_64.rpm

centos7:

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

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

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

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

yum localinstall -y mysql-community*.rpm

報錯:

Error: Package: 2:postfix-2.6.6-6.el6_7.1.x86_64 (localyum)

Requires: libmysqlclient.so.16(libmysqlclient_16)(64bit)

Removing: mysql-libs-5.1.71-1.el6.x86_64 (@anaconda-CentOS-201311272149.x86_64/6.5)

libmysqlclient.so.16(libmysqlclient_16)(64bit)

Obsoleted By: mysql-community-libs-5.7.15-1.el6.x86_64 (/mysql-community-libs-5.7.15-1.el6.x86_64)

Not found

Updated By: mysql-libs-5.1.73-7.el6.x86_64 (localyum)

libmysqlclient.so.16(libmysqlclient_16)(64bit)

Error: Package: 2:postfix-2.6.6-6.el6_7.1.x86_64 (localyum)

Requires: libmysqlclient.so.16()(64bit)

Removing: mysql-libs-5.1.71-1.el6.x86_64 (@anaconda-CentOS-201311272149.x86_64/6.5)

libmysqlclient.so.16()(64bit)

Obsoleted By: mysql-community-libs-5.7.15-1.el6.x86_64 (/mysql-community-libs-5.7.15-1.el6.x86_64)

Not found

Updated By: mysql-libs-5.1.73-7.el6.x86_64 (localyum)

libmysqlclient.so.16()(64bit)

You could try using --skip-broken to work around the problem

You could try running: rpm -Va --nofiles --nodigest

解決辦法:

rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64

1)默認 root 密碼為空,其實不為空,使用 mysql -u root -p 進行登錄失敗

2)mysql_secure_installation這個初始化也不行

直接編輯mysql配置文件

vim /etc/my.cnf

加入

skip-grant-tables

注意:要加在[mysqld]的位置

重啟數據庫

#進入 mysql控制臺

# mysql

可能的報錯:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)

解決辦法:加上-h127.0.0.1

[root@node2 bin]# mysql -h127.0.0.1 -uroot -p

Enter password:

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

Your MySQL connection id is 3

Server version: 5.7.15 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> show databases;

+--------------------+

| Database ? ? ? ? ? |

+--------------------+

| information_schema |

| mysql ? ? ? ? ? ? ?|

| performance_schema |

| sys ? ? ? ? ? ? ? ?|

+--------------------+

4 rows in set (0.13 sec)

>use mysql;

# 修改密碼

>update user set authentication_string = password('yourpasswd'), password_expired = 'N', password_last_changed = now() where user = 'root';

刪掉skip-grant-tables,再次重啟即可

添加用戶時,報錯,是因為密碼策略的問題,我們只是測試,密碼不需要那么復雜

mysql> grant all privileges on test.* to jack@'%' identified by "test";

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

修改密碼策略即可

mysql> set global validate_password_policy=0;

mysql5.7開發環境的配置示例:

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

max_connections=1024

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

symbolic-links=0

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_UNSIGNED_SUBTRACTION"

[client]

default-character-set = utf8mb4

[mysql]

default-character-set = utf8mb4

[mysqld]

character-set-client-handshake = FALSE

character-set-server = utf8mb4

collation_server = utf8mb4_general_ci

init_connect='SET NAMES utf8mb4'

ucloud mysql5.7配置:

[client]

default-character-set = utf8mb4

[mysql]

default-character-set = utf8mb4

[mysqld]

back_log = 2000

basedir = /opt/udb/program/mysql/mysql-5.7.12

bind-address = 127.0.0.1

binlog-format = MIXED

character-set-client-handshake = 0

character_set_server = utf8mb4

datadir = /opt/udb/instance/mysql-5.7/xxxxxxxx/data

event_scheduler = ON

expire_logs_days = 7

general-log-file = /opt/udb/instance/mysql-5.7/xxxxxxxx/log/mysqld.log

init_connect = 'SET NAMES utf8mb4'

innodb_buffer_pool_size = 377487360

innodb_data_file_path = ibdata1:100M:autoextend

innodb_data_home_dir = /opt/udb/instance/mysql-5.7/xxxxxxxx/data

innodb_file_per_table = 1

innodb_flush_log_at_trx_commit = 2

innodb_flush_method = O_DIRECT

innodb_io_capacity = 2000

innodb_log_buffer_size = 8388608

innodb_log_file_size = 512M

innodb_log_files_in_group = 2

innodb_log_group_home_dir = /opt/udb/instance/mysql-5.7/xxxxxxxx/data

innodb_max_dirty_pages_pct = 50

innodb_open_files = 1024

innodb_read_io_threads = 8

innodb_thread_concurrency = 20

innodb_write_io_threads = 8

key_buffer_size = 33554432

local_infile = 1

log-bin = /opt/udb/instance/mysql-5.7/xxxxxxxx/binlog/mysql-bin.log

log-error = /opt/udb/instance/mysql-5.7/xxxxxxxx/log/mysqld.log

log_bin_trust_function_creators = 1

log_output = TABLE

long_query_time = 3

max_allowed_packet = 16777216

max_connect_errors = 1000000

max_connections = 2000

myisam_sort_buffer_size = 8388608

net_buffer_length = 8192

performance_schema = 0

performance_schema_max_table_instances = 200

pid-file = /opt/udb/instance/mysql-5.7/xxxxxxxx/mysqld.pid

port = 3306

query_cache_size = 16777216

read_buffer_size = 262144

read_rnd_buffer_size = 524288

relay-log = /opt/udb/instance/mysql-5.7/xxxxxxxx/relaylog/mysql-relay.log

secure-file-priv = /opt/udb/instance/mysql-5.7/xxxxxxxx/tmp

server-id = 2130706433

skip-slave-start

skip_name_resolve

slave-load-tmpdir = /opt/udb/instance/mysql-5.7/xxxxxxxx/tmp

slave-parallel-type = LOGICAL_CLOCK

slave_parallel_workers = 8

slow-query-log-file = /opt/udb/instance/mysql-5.7/xxxxxxxx/log/mysql-slow.log

slow_query_log = 1

socket = /opt/udb/instance/mysql-5.7/xxxxxxxx/mysqld.sock

sort_buffer_size = 524288

sql_mode = STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_UNSIGN

sync_binlog = 1

table_open_cache = 128

thread_cache_size = 50

tmpdir = /opt/udb/instance/mysql-5.7/xxxxxxxx/tmp

user = mysql

[mysqld_safe]

log-error = /opt/udb/instance/mysql-5.7/xxxxxxxx/log/mysqld.log

pid-file = /opt/udb/instance/mysql-5.7/xxxxxxxx/mysqld.pid

centos6.5環境安裝mysql5.6

操作系統:centos6.5 x86_64

1.檢查下linux是不是已經安裝了mysql

rpm -qa | grep -i mysql

#如果安裝了先卸載舊的版本

rpm -e --nodeps mysql...

2.下載需要的安裝包,下載地址:

http://dev.mysql.com/downloads/mysql/5.6.html#downloads

MySQL-client-5.6.34-1.el6.x86_64.rpm

MySQL-devel-5.6.34-1.el6.x86_64.rpm

MySQL-server-5.6.34-1.el6.x86_64.rpm

全部安裝

rpm -ivh MySQL-*.rpm

3.修改配置文件位置并做相關設置

cp /usr/share/mysql/my-default.cnf /etc/my.cnf

vi /etc/my.cnf

如果之前的版本有安裝,需要重置root密碼,可以在my.cnf的mysqld步伐加入,重啟mysql,不輸入密碼即可進數據庫

skip-grant-tables

密碼默認位置:

# cat /root/.mysql_secret

4.初始化MySQL及設置密碼

/usr/bin/mysql_install_db

service mysql start

可能碰到的錯誤:

明明已經修改了mysql.user表中的root密碼,執行命令報錯:

mysql> show databases;

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql> use mysql;

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

解決辦法:

mysql> SET PASSWORD = PASSWORD('123');

Query OK, 0 rows affected (0.00 sec)

總結

以上是生活随笔為你收集整理的centos mysql rpm re_centos7和centos6.5环境rpm方式安装mysql5.7和mysql5.6详解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。