Linux下mysql8.0.27安装⼀、下载
1、检查是否安装了mysql
1)rpm -qa | grep mysql
2)如果安装过,执⾏删除
rpm -e --nodeps [版本]
2、下载地址:
选择对应包进⾏下载
⼆、安装
1、解压
tar xvf mysql-8.0.27-linux-glibc2.12-x86_ 2、配置
1)创建mysql组和⽤户
groupadd mysql
useradd -r -g mysql mysql
2)在mysql⽬录下创建data⽬录
3)更改mysql ⽬录内所有⽂件⽤户组和权限
chown -R mysql:mysql /usr/local/myapp/mysql/mysql-8.0.27
chmod -R 755 /usr/local/myapp/mysql/mysql-8.0.27
4)创建myf ⽂件(⽤于初始化
数据库)
默认读取顺序:
vim /etc/myf,复制以下代码
1
/etc/myf 2
3
/etc/mysql/myf
4
5
/usr/local/mysql/etc/myf 6 7~/.myf 1
[mysql]2
# 设置mysql 客户端默认字符集3
default-character-set=utf8mb44
[client]5
port      = 33066
socket    = /tmp/mysql.sock 7
8
[mysqld]9
port      = 330610
server-id  = 330611
user      = mysql 12
socket    = /tmp/mysql.sock 13
# 设置mysql 的安装⽬录14
basedir    = /usr/local/myapp/mysql/mysql-8.0.2715
# 设置mysql 数据库的数据的存放⽬录16
datadir    = /usr/local/myapp/mysql/mysql-8.0.27/data 17
log-bin    = /usr/local/myapp/mysql/mysql-8.0.27/data/mysql-bin 18
innodb_data_home_dir = /usr/local/myapp/mysql/mysql-8.0.27/data 19
innodb_log_group_home_dir = /usr/local/myapp/mysql/mysql-8.0.27/data 20
#设置mysql 数据库的⽇志及进程数据的存放⽬录21
log-error = /usr/local/myapp/mysql/mysql-8.0.27/data/mysql.log 22
pid-file  = /usr/local/myapp/mysql/mysql-8.0.27/data/mysql.pid 23
# 服务端使⽤的字符集默认为8⽐特编码24
character-set-server=utf8mb425
lower_case_table_names=126autocommit =127
27
28>>>###以上要修改的>>>>####
29skip-external-locking
30key_buffer_size = 256M
31max_allowed_packet = 1M
32table_open_cache = 1024
33sort_buffer_size = 4M
34net_buffer_length = 8K
35read_buffer_size = 4M
36read_rnd_buffer_size = 512K
之前下过mysql现在重新下载mysql
37myisam_sort_buffer_size = 64M
38thread_cache_size = 128
39
40#query_cache_size = 128M
41tmp_table_size = 128M
42explicit_defaults_for_timestamp = true
43max_connections = 500
44max_connect_errors = 100
45open_files_limit = 65535
46
47binlog_format=mixed
48
49binlog_expire_logs_seconds =864000
50
51# 创建新表时将使⽤的默认存储引擎
52default_storage_engine = InnoDB
53innodb_data_file_path = ibdata1:10M:autoextend
54innodb_buffer_pool_size = 1024M
55innodb_log_file_size = 256M
56innodb_log_buffer_size = 8M
57innodb_flush_log_at_trx_commit = 1
58innodb_lock_wait_timeout = 50
59transaction-isolation=READ-COMMITTED
60
61[mysqldump]
62quick
63max_allowed_packet = 16M
64
65[myisamchk]
66key_buffer_size = 256M
67sort_buffer_size = 4M
68read_buffer = 2M
69write_buffer = 2M
70
71[mysqlhotcopy]
72interactive-timeout
5)初始化mysql
进⼊bin⽬录,执⾏./mysqld --defaults-file=/etc/myf --basedir=/usr/local/myapp/mysql/mysql-8.0.27 --datadir=/usr/local/myapp/mysql/mysql-8.0.27/data/ --user=mysql --initialize
1参数说明
2
3--defaults-file=/usr/local/etc/myf 指定配置⽂件(--initialize 之前)
4--user=mysql 指定⽤户(很关键)
5--basedir=/usr/local/mysql/ 指定安装⽬录
6--datadir=/usr/local/mysql/data/ 指定初始化数据⽬录
执⾏成功
注:遇到的情况
1第⼀种情况:
2error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory 3解决⽅法:yum install libaio
4
5第⼆种情况:
6error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory 7解决⽅法:sudo ln -s /usr/lib64/libtinfo.so.6.1 /usr/lib64/libtinfo.so.5
6)开启mysql服务
进⼊support-files⽬录,运⾏mysql.server start
7)登录mysql
查看mysql.log⽂件,到临时密码
登录mysql,进⼊bin⽬录,运⾏./mysql -u root -p
8)修改密码
修改密码:ALTER USER USER() IDENTIFIED BY 'yourpass';
刷新权限:flush privileges;

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。

发表评论