linux安装mysql8依赖的环境_linux安装mysql8.0.19详细步骤及
问题解决⽅法
最近买了个腾讯云服务器,搭建环境。
该笔记⽤于系统上未装过mysql的⼲净系统第⼀次安装mysql。⾃⼰指定安装⽬录,指定数据⽂件⽬录。
linux系统版本: centos 7.3 64位
安装源⽂件版本:mysql-5.7.21-linux-glibc2.12-x86_
mysql安装位置:/software/mysql
数据库⽂件数据位置:/data/mysql
注:未防⽌混淆,这⾥都⽤绝对路径执⾏命令
除了⽂件内容中的#,这⾥所有带#都是linux命令
>mysql 是mysql的命令
步骤:
1、在根⽬录下创建⽂件夹software和数据库数据⽂件/data/mysql
#mkdir /software/
#mkdir /data/mysql
2、上传mysql-8.0.19-linux-glibc2.12-x86_⽂件到/software下
--------------------
这⾥我下载的带了router和test的mysql-8.0.19-linux-glibc2.12-x86_64.tar⽂件,所以多⼀部解压xz
--------------------
#cd /software/
#xz -d mysql-8.0.19-linux-glibc2.12-x86_
#tar -xvf mysql-8.0.19-linux-glibc2.12-x86_64.tar
3、更改解压缩后的⽂件夹名称
#mv /software/mysql-8.0.19-linux-glibc2.12-x86_64/ /software/mysql
4、创建mysql⽤户组和mysql⽤户
#groupadd mysql
#useradd -r -g mysql mysql
5、关联myql⽤户到mysql⽤户组中
#chown -r mysql:mysql /software/mysql/
#chown -r mysql:mysql /data/mysql/
#chown -r mysql /software/mysql/
#chown -r mysql /data/mysql
6、更改mysql安装⽂件夹mysql/的权限
#chmod -r 755 /software/mysql/
7、安装libaio依赖包,系统⾃带的有这个依赖包所以不需要安装,不过⾃带的依赖包会报错
查询是否暗转libaio依赖包
#yum search libaio
如果没安装,可以⽤下⾯命令安装
#yum install libaio
8、初始化mysql命令
#cd /software/mysql/bin
#./mysqld --user=mysql --basedir=/software/mysql --datadir=/data/mysql --initialize 在执⾏上⾯命令时特别要注意⼀⾏内容
[note] a temporary password is generated for : o*s#gqh)f4ck
: 后⾯跟的是mysql数据库登录的临时密码,各⼈安装⽣成的临时密码不⼀样
如果初始化时报错如下:
error while loading shared libraries: libnuma.so.1: cannot open shared objec
是因为libnuma安装的是32位,我们这⾥需要64位的,执⾏下⾯语句就可以解决
#yum install numactl.x86_64
执⾏完后重新初始化mysql命令
9、启动mysql服务
# sh /software/mysql/support-files/mysql.server start
上⾯启动mysql服务命令是会报错的,因为没有修改mysql的配置⽂件,报错内容⼤致如下:./support-files/mysql.server: line 239: my_print_defaults: command not found
./support-files/mysql.server: line 259: cd: /usr/local/mysql: no such file or directory starting mysql error! couldn't find mysql server (/usr/local/mysql/bin/mysqld_safe) 10、修改mysql配置⽂件
#vim /software/mysql/support-files/mysql.server
修改前
if test -z "$basedir"
then
basedir=/usr/local/mysql
bindir=/usr/local/mysql/bin
if test -z "$datadir"
then
datadir=/usr/local/mysql/data
fi
sbindir=/usr/local/mysql/bin
libexecdir=/usr/local/mysql/bin
else
bindir="$basedir/bin"
if test -z "$datadir"
then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
fi
修改后
if test -z "$basedir"
then
basedir=/software/mysql
bindir=/software/mysql/bin
if test -z "$datadir"
then
datadir=/data/mysql
fi
sbindir=/software/mysql/bin
libexecdir=/software/mysql/bin
else
bindir="$basedir/bin"
if test -z "$datadir"
mysql下载配置then
datadir="$basedir/data"
fi
sbindir="$basedir/sbin"
libexecdir="$basedir/libexec"
fi
保存退出
#cp /software/mysql/support-files/mysql.server /etc/init.d/mysqld #chmod 755 /etc/init.d/mysqld
11、修改myf⽂件
#vi /etc/myf
将下⾯内容复制替换当前的myf⽂件中的内容
[client]
no-beep
socket =/software/mysql/mysql.sock
# pipe
# socket=0.0
port=3306
[mysql]
#原⽂的utf8指向utf8mb3,后续版本要改为utf8mb4,⼀步到位吧default-character-set=utf8mb4
[mysqld]
basedir=/software/mysql
datadir=/data/mysql
port=3306
pid-file=/software/mysql/mysqld.pid
#skip-grant-tables
skip-name-resolve
socket = /software/mysql/mysql.sock
character-set-server=utf8
default-storage-engine=innodb
explicit_defaults_for_timestamp = true
# server id.
server-id=1
max_connections=2000
#query_cache_size在8.0版本已经移除,故注释
#query_cache_size=0
table_open_cache=2000
tmp_table_size=246m
thread_cache_size=300
#限定⽤于每个数据库线程的栈⼤⼩。默认设置⾜以满⾜⼤多数应⽤thread_stack = 192k
key_buffer_size=512m
read_buffer_size=4m
read_rnd_buffer_size=32m
innodb_data_home_dir = /data/mysql
innodb_flush_log_at_trx_commit=0
innodb_log_buffer_size=16m
innodb_buffer_pool_size=256m
innodb_log_file_size=128m
innodb_thread_concurrency=128
innodb_autoextend_increment=1000
innodb_buffer_pool_instances=8
innodb_concurrency_tickets=5000
innodb_old_blocks_time=1000
innodb_open_files=300
innodb_stats_on_metadata=0
innodb_file_per_table=1
innodb_checksum_algorithm=0
back_log=80
flush_time=0
join_buffer_size=128m
max_allowed_packet=1024m
max_connect_errors=2000
open_files_limit=4161
#query_cache_type在8.0版本已经移除,故注释
#query_cache_type=0
sort_buffer_size=32m
table_definition_cache=1400
binlog_row_event_max_size=8k
sync_master_info=10000
sync_relay_log=10000
sync_relay_log_info=10000
#批量插⼊数据缓存⼤⼩,可以有效提⾼插⼊效率,默认为8m bulk_insert_buffer_size = 64m
interactive_timeout = 120
wait_timeout = 120
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论