1、下载mysql8安装包linux 版本
mysql-8.0.25-linux-glibc2.12-x86_64.tar
2、创建文件夹 并进入到文件夹中,文件夹名称随便取
mkdir /env;
cd env;
3、上传mysql包,可以使用linux 的rz命令上传,如果找不到命令,先安装下命令
yum install -y lrzsz
4、解压mysql包
tar -xvf mysql-8.0.25-linux-glibc2.12-x86_64.tar.xz
5、移动解压后的文件夹到/usr/local/mysql
mv mysql-8.0.25-linux-glibc2.12 /usr/local/mysql
6、创建data文件夹,一般用于存放数据库文件数据
mkdir /usr/local/mysql/data
7、创建用户组
groupadd mysql;
useradd -g mysql mysql;
8、更改用户文件夹权限
chown -R mysql.mysql /usr/local/mysql/
9、生成my.cnf文件
touch /etc/my.cnf
10、编辑my.cnf
[mysql]
default-character-set=utf8
[mysqld]
port=3306
default_authentication_plugin=mysql_native_password
socket = /usr/local/mysql/mysql.sock
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data/
character-set-server=utf8
default-storage-engine=InnoDB
collation-server=utf8_unicode_ci
init_connect='SET NAMES utf8'
innodb_buffer_pool_size=512M
innodb_flush_log_at_trx_commit=0
innodb_lock_wait_timeout=31536000
innodb_log_buffer_size=8M
innodb_log_file_size=16M
join_buffer_size=200M
key_buffer_size=400M
log-error=/usr/local/mysql/mysql.log
pid-file=/usr/local/mysql/mysql.pid
log_error_verbosity=1
max_allowed_packet=2000M
max_connections=1000
max_heap_table_size=6400M
myisam_max_sort_file_size=64M
myisam_sort_buffer_size=32M
read_buffer_size=4M
read_rnd_buffer_size=4000M
server_id=1
skip-external-locking=on
sort_buffer_size=256kb
table_open_cache=256
thread_cache_size=16
tmp_table_size=64M
wait_timeout=31536000
interactive_timeout=31536000
sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
group_concat_max_len=10240
[client]
port=3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
11、再次更改用户文件夹权限
chown -R mysql:mysql /usr/local/mysql
12、初始化数据库
/usr/local/mysql/bin/mysqld --user=mysql --initialize --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
备注:这里可能会报错 提示
error while loading shared libraries: libaio.so.1: cannot open shared object file directory
可以执行以下命令
yum install libaio-devel.x86_64
13、继续执行初始化数据库命令
/usr/local/mysql/bin/mysqld --user=mysql --initialize --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
14、查看初始化密码 日志文件在 /usr/local/mysql/mysql.log
15、修改配置,挨个执行,如果报错,跳过
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
16、修改环境变量,并重载环境变量文件,打开 /etc/profile 在底部添加如下命令
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
export PATH
执行
source /etc/profile
17、启动mysql
service mysql start
18、登录mysql,密码是上面的初始化密码
mysql -uroot -p;
19、第一次登录必须要先修改密码不然会提示
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
执行修改密码命令
alter user 'root'@'localhost' identified by '密码';
20、授权远程访问文章来源:https://www.toymoban.com/news/detail-411851.html
update user set host='%' where user='root'
21、查看防火墙或者是组策略是否放行了3306端口文章来源地址https://www.toymoban.com/news/detail-411851.html
到了这里,关于linux 安装mysql8 error while loading shared libraries: libaio.so.1: cannot open shared object file directory的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!