记录在centos7上安装的mysql5.7

1、下载源文件

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

2、安装源

yum -y install mysql57-community-release-el7-10.noarch.rpm

3、卸载自带mariadb

rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.35-3.el7.x86_64

4、安装mysql5.7

yum -y install mysql-community-server

5、修改my.cnf配置文件

cp /etc/my.cnf /etc/my.cnf.bak

然后将如下内容写入 /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[client]
#客户端设置
port    = 3306
default-character-set = utf8mb4
socket=/data/mysql/mysql.sock

[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
port    = 3306
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
datadir=/data/mysql
socket=/data/mysql/mysql.sock
# 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

#系统数据库编码设置,排序规则
character_set_server = utf8mb4
collation_server = utf8mb4_bin
back_log = 1024
explicit_defaults_for_timestamp = ON
lower_case_table_names = 0
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
 
max_connections = 512
max_connect_errors = 1000000
table_open_cache = 1024
max_allowed_packet = 8M
thread_stack = 256K
thread_cache_size = 384
 
skip-external-locking
 
interactive_timeout = 600
wait_timeout = 3600

log_timestamps = SYSTEM

#默认使用InnoDB存储引擎
default_storage_engine = InnoDB
innodb_buffer_pool_size = 64M
innodb_purge_threads = 1
innodb_log_buffer_size = 2M
innodb_log_file_size = 128M
innodb_lock_wait_timeout = 120
 
bulk_insert_buffer_size = 32M
myisam_sort_buffer_size = 8M
# MySQL重建索引时所允许的最大临时文件的大小
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
lower_case_table_names=1

6、启动mysql

systemctl start  mysqld.service

可以使用systemctl status mysqld.service查看状态,使用systemctl stop mysqld.service停止mysql

7、查看mysql临时密码

grep "password is generated" /var/log/mysqld.log | awk '{print $NF}'

8、连接mysql

[root@ecs-1473-0005 etc]# mysql -uroot -p
Enter password: 

然后输入刚才查到的密码,并回车后进入mysql。

9、修改临时密码

alter user user() identified by "你的密码";

 

版权声明:
作者:Miigua
链接:https://www.miigua.com/article/330.html
来源:米瓜的博客
文章版权归作者所有,未经允许请勿转载。

THE END
二维码
打赏
请在后台主题设置处设置打赏图片
< <上一篇
下一篇>>