一、下载linux mysql8.0 离线安装包
mysql下载地址:https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
mysql官方下载最新版本:https://dev.mysql.com/downloads/mysql/
然后选择 linux
把下载的压缩包上传到要安装的服务器上,解压mysql tar xvJf mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz
二、rz/rs 上传下载命令
1. 安装
yum install lrzsz -y
2. 使用
# 上传
rz -bey
# 下载
sz -bey file1 file2 file3
选项说明:
-+, --append:将文件内容追加到已存在的同名文件
-a,--ascii:以文本方式传输
-b, --binary:以二进制方式传输,推荐使用
--delay-startup N:等待N秒
-e, --escape:对所有控制字符转义,建议使用
-E, --rename:已存在同名文件则重命名新上传的文件,以点和数字作为后缀
-p, --protect:对ZMODEM协议有效,如果目标文件已存在则跳过 -
q, --quiet:安静执行,不输出提示信息
-v, --verbose:输出传输过程中的提示信息
-y, --overwrite:存在同名文件则替换
-X, --xmodem:使用XMODEM协议
--ymodem:使用YMODEM协议
-Z, --zmodem:使用ZMODEM协议
--version:显示版本信息
--h, --help:显示帮助信息
二、安装mysql
在 /usr/local
目录下创建mysql文件夹 mkdir mysql
切换到mysql目录下 cd /usr/local/mysql
# 解压mysql
[root@localhost /usr/local/mysql]# tar xvJf mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz
# 移动/重命名文件夹
[root@localhost /usr/local/mysql]# mv mysql-8.0.21-linux-glibc2.12-x86_64 mysql-8.0
# 创建 data 文件夹 储存文件
[root@localhost /usr/local/mysql]# cd mysql-8.0
[root@localhost /usr/local/mysql/mysql-8.0]# mkdir data
# 创建用户组以及用户和密码
[root@localhost /usr/local/mysql/mysql-8.0]# groupadd mysql
[root@localhost /usr/local/mysql/mysql-8.0]# useradd -g mysql mysql
# 授权用户
[root@localhost /usr/local/mysql/mysql-8.0]# chown -R mysql.mysql /usr/local/mysql/mysql-8.0
# 切换到bin目录下,初始化基础信息
[root@localhost /usr/local/mysql/mysql-8.0]# cd bin
[root@localhost /usr/local/mysql/mysql-8.0/bin]# ./mysqld --user=mysql --basedir=/usr/local/mysql/mysql-8.0 --datadir=/usr/local/mysql/mysql-8.0/data/ --initialize --lower-case-table-names=1
得到临时密码
编辑 my.cnf
(没有就新建一个 touch my.cnf
) vim /etc/my.cnf 注释mysqld_safe
修改信息
[mysqld]
basedir=/usr/local/mysql/mysql-8.0/
datadir=/usr/local/mysql/mysql-8.0/data/
socket=/tmp/mysql.sock
character-set-server=UTF8MB4
lower_case_table_names = 1
# 添加mysqld服务到系统
[root@localhost /usr/local/mysql/mysql-8.0]# cp -a ./support-files/mysql.server /etc/init.d/mysql
# 授权以及添加服务
[root@localhost /usr/local/mysql/mysql-8.0]# chmod +x /etc/init.d/mysql
[root@localhost /usr/local/mysql/mysql-8.0]# chkconfig --add mysql
# 启动 mysql
[root@localhost /usr/local/mysql/mysql-8.0]# service mysql start
# 查看启动状态
[root@localhost /usr/local/mysql/mysql-8.0]# service mysql status
# 将mysql命令添加到服务
[root@localhost /usr/local/mysql/mysql-8.0]# ln -s /usr/local/mysql/mysql-8.0/bin/mysql /usr/bin
# 登录mysql(使用临时密码)
[root@localhost /usr/local/mysql/mysql-8.0]# mysql -uroot -p
# 修改root密码并刷新使密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxxxx';
flush privileges;
# 选择mysql数据库
use mysql;
# 修改远程连接并生效
update user set host='%' where user='root';
flush privileges;
三、问题
- 报错:Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/mysql-8.0/bin/mysqld_safe)
解决:
chmod a+wrx /usr/local/mysql/mysql-8.0/bin/mysqld_safe
授权后在运行 service mysql start
即可
- 报错:my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
/etc/init.d/mysql: line 259: cd: /usr/local/mysql: No such file or directory
Starting MySQL ERROR! Couldn’t find MySQL server (/usr/local/mysql/mysql-8.0/bin/mysqld_safe)
解决:
编辑my.cnf开头加[mysqld]
- 报错:Starting MySQL… ERROR! The server quit without updating PID file (/usr/local/mysql/mysql-8.0/data/mysql-data/localhost.localdomain.pid).
解决:
修改mysql-data的权限为root
chown -R root:root .
chown -R mysql:mysql .
- 报错:error: ‘Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)’
解决:
虽然socket的值已经配置但是还是提示的默认路径,因此新建软连接
ln -s /usr/local/mysql/mysql-8.0/data/mysql-data/mysql.sock /tmp/mysql.sock
- 报错:ln: failed to create symbolic link ‘/tmp/mysql.sock’: File exists
解决:
由于之前已经建立过软连接,所以此处修改软连接就可以
ln -snf /usr/local/mysql/mysql-8.0/data/mysql-data/mysql.sock /tmp/mysql.sock
- 报错:Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/mysql-8.0/data/mysql-data/localhost.localdomain.pid).
解决:
因为新建的文件夹binlog没有赋予mysql权限
chown -R mysql:mysql /usr/local/data/mysql-data/binlog
- 报错:初始化启动报错,查看日志报错
Different lower_case_table_names settings for server (‘0’) and data dictionary (‘1’):
Data Dictionary initialization failed.
Aborting
解决:
MySQL8.0 要求 lower-case-table-names 在数据库初始化和启动时的值必须一致,因此需要同时将 my.cnf 中的 lower-case-table-names 设置为 1 :
[mysqld]
lower_case_table_names = 1
参考链接:
https://blog.csdn.net/maxushan001/article/details/121475649
标签:8.0,--,root,linux,离线,mysql8.0,usr,mysql,local From: https://www.cnblogs.com/2393920029-qq/p/16729692.html