rpm 包方式安装mysql

官网下载 需要使用的rpm包

https://downloads.mysql.com/archives/community/

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

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

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

mysql-community-client-plugins-8.0.23-1.el7.x86_64.rpm

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

rpm -ivh xxx.rpm 

如果安装过程有如下报错

 

 需要在后面加上 rpm -ivh xxx.rpm  --force --nodeps

安装完成后

修改mysql的配置文件,首先要确认配置文件的位置

which mysql

 

然后到这个路径下 ,执行  mysql --verbose --help|grep -A 1 'Default options'

 

第一个是首先默认加载的配置文件

vi /etc/my.cnf  添加如下配置

basedir=/var/lib/mysql
datadir=/var/lib/mysql/data
socket=/var/lib/mysql/mysql.sock

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

default_authentication_plugin=mysql_native_password
max_allowed_packet = 1G
innodb_log_file_size = 30M
innodb_log_buffer_size = 512M
innodb_buffer_pool_size=8G
innodb_file_per_table = 1
max_connections=2000
innodb_strict_mode = 0
character_set_server=UTF8MB3
default-time-zone='+8:00'
transaction-isolation = READ-COMMITTED
lower_case_table_names = 1
port = 3306

 

执行 service mysqld start 启动mysql服务

然后 通过名 grep 'temporary password' /var/log/mysqld.log 查看mysql root用户的初始随机密码

mysql -uroot -p 启动sqlcmd

首次修改root用户密码执行

alter user user() identified by "Test1027?!";

 

检查字符集 以及版本,确认安装成功

mysql -uroot -p

然后输入刚刚修改的密码

执行select version();

 

 

然后 show variables like '%character%';  查询字符集

 

posted @ 2021-09-21 16:24  小清澈  阅读(257)  评论(0编辑  收藏  举报