下载安装包链接
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.31-linux-glibc2.12-x86_64.tar.xz
下载安装包
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.31-linux-glibc2.12-x86_64.tar.xz
1.解压文件
tar -xvf mysql-8.0.31-linux-glibc2.12-x86_64.tar.xz
2.移动到合适的目录
sudo mv mysql-8.0.31 /usr/local/mysql
3.在/usr/local/mysql目录下新建一个etc文件夹
mkdir etc
4.创建my.cnf文件
touch my.cnf
5.授予权限
chmod 644 /usr/local/mysql/etc/my.cnf
6.编辑my.cnf文件,填入以下内容
vim my.cnf
[mysqld]
default-time-zone='+08:00'
bind-address=0.0.0.0
port=46033
user=mysql
socket=/tmp/mysql46033.sock
pid_file=/data/mysql/data/data_46033/data/my.pid
basedir=/usr/local/mysql
datadir=/data/mysql/data/data_46033/data
#character config
character_set_server=utf8mb4
explicit_defaults_for_timestamp=true
symbolic-links=0
log-error=/data/mysql/data/data_46033/logs/mysql46033.err
log_bin = /data/mysql/data/data_46033/binlog/mysql-bin
relay_log = /data/mysql/data/data_46033/relaylog/relay-bin
slow_query_log_file = /data/mysql/data/data_46033/logs/slow.log
slow_query_log=on
server-id=6
#innodb settings
innodb_buffer_pool_size=128M
#skip-grant-tables
gtid-mode=on
enforce-gtid-consistency=true
log-slave-updates=1
lower_case_table_names=1
default_authentication_plugin=mysql_native_password[mysql]
socket = /tmp/mysql46033.sock
#plugin-load=validate_password.so
#validate-password=FORCE_PLUS_PERMANENT
7.创建一个data目录
mkdir -p /data/mysql/data/data_46033
8.在data里建立这个四个目录
cd /data/mysql/data/data_46033/
mkdir binlog
mkdir logs
mkdir data
mkdir relaylog
9.创建mysql 用户组和用户
groupadd mysql
useradd -r -g mysql mysql
10.赋予权限
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /data/mysql/data
11.MySQL初始化
cd /usr/local/mysql/bin
./mysqld --defaults-file=/usr/local/mysql/etc/my.cnf --initialize-insecure
12.启动MySQL
/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf &
13.查看是否启动成功
ps -ef|grep mysql
14.配置环境变量
vim /etc/profile +
将下面内容添加到最后一行
export PATH=/usr/local/mysql/bin:$PATH
15.从新加载配置文件
source /etc/profile
16.设置密码(不需要输入密码直接回车)
mysql -S /tmp/mysql46033.sock -u root -p
17.配置远程连接&修改密码
配置远程连接
update user set Host='%' where User='root';
修改MySQL管理员密码
ALTER USER 'root'@'%' IDENTIFIED BY 'rootCX123#@!';
刷新权限
flush privileges;创建临时超级用户
create user 'mongolia'@'%' identified by 'mongoliaCX123#@!';
授权所有特权
GRANT ALL PRIVILEGES ON *.* TO 'mongolia'@'%' WITH GRANT OPTION;
刷新权限
flush privileges;
注意:修改密码后,可能会启动失败。
解决方法如下:
1.执行ps aux |grep mysqld
2.杀死进程
kill -9 进程号
3.重新启动MySQL
/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf &# Redhat8.6安装MySQL8.0时提示libncurses.so.5不存在的解决方案
问题1: 缺少libncurses.so.5
find / -name 'libncurses*'
解决方法是创建一个指向高版本库文件的符号链接(软链接),模拟出libncurses.so.5
ln -s /usr/lib64/libncurses.so.6 /usr/lib64/libncurses.so.5问题2: 缺少libtinfo.so.5
find / -name 'libtinfo.so*'
处理方法,创建一个指向libtinfo.so.6的符号链接来解决问题
ln -s /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.5