Linux Cent7 已安装MySQL5.7.X,再安装MYSQL8.4.2
2024/11/18 23:01:39
来源:https://blog.csdn.net/l1179237106/article/details/142706231
浏览:
次
关键词:Linux Cent7 已安装MySQL5.7.X,再安装MYSQL8.4.2
一、 下载安装
- 检查Linux系统的glibc版本
rpm -qa | grep glibc
结果:glibc-common-2.17-260.el7_6.6.x86_64
glibc-2.17-260.el7_6.6.x86_64
glibc-headers-2.17-260.el7_6.6.x86_64
glibc-devel-2.17-260.el7_6.6.x86_64
- 访问MySQL官网,下载对应版本数据库
- 上传服务器并解压
解压xz文件成tarxz -d mysql-8.4.2-linux-glibc2.17-x86_64.tar.xz
解压tar文件,然后重命名成“mysql-8.4.2”tar -xvf mysql-8.4.2-linux-glibc2.17-x86_64.tar -C ./
二、数据库服务部署
- 赋予权限
chown -R mysql.mysql ./mysql-8.4.2
- 创建配置文件
vim ./mysql-8.4.2/my.cnf
“my.cnf”配置内容:[client]
port=3307mysqlx_port=33070
socket=/tmp/mysql84.sock
mysqlx_socket=/tmp/mysqlx84.sock[mysqld]
# skip-grant-tables
# mysql安装目录
basedir=/usr/local/mysql-8.4.2
# mysql数据库目录
datadir=/usr/local/mysql-8.4.2/data
port=3307
innodb_file_per_table=1
character-set-server=utf8
mysqlx_port=33070
socket = /tmp/mysql84.sock
mysqlx_socket=/tmp/mysqlx80.sock[mysqld_safe]
# 错误日志
log-error=/usr/local/mysql-8.4.2/data/error.log
# pid文件
pid-file=/usr/local/mysql-8.4.2/data/mysqld.pid
tmpdir=/tmp/mysql84
- 赋予配置文件权限
chmod 755 ./mysql-8.4.2/my.cnf
- 修改服务器文件
vim ./mysql-8.4.2/support-files/mysql.server
“mysql.server”修改内容:basedir=/usr/local/mysql-8.4.2
datadir=/usr/local/mysql-8.4.2/datalockdir='/var/lock/subsys'
lock_file_path="$lockdir/mysql84" mysqld_pid_file_path=/usr/local/mysql-8.4.2/data/mysqld.pidconf=/usr/local/mysql-8.4.2/my.cnf
- 复制注册连接服务文件
cp -i ./mysql-8.4.2/support-files/mysql.server /etc/init.d/mysql84
- 初始化数据库
./mysql-8.4.2/bin/mysqld --defaults-file=/usr/local/mysql-8.4.2/my.cnf --user=mysql --initialize
初始化成功,查看输出日志,找到初始密码2024-10-04T12:06:18.478525Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: XH>)njhBE5VC
三、数据库账号配置
- 启动数据库
/usr/local/mysql-8.4.2/bin/mysqld_safe --defaults-file=/usr/local/mysql-8.4.2/my.cnf
- 登录数据库
./mysql-8.4.2/bin/mysql --socket=/tmp/mysql84.sock -u root -p
- 修改初始密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;
- 运行远程登录
use mysql;
update user set user.Host ='%' where user.User='root';
flush privileges;