Linux上在线安装mysql

查询mysql版本

https://dev.mysql.com/downloads/repo/yum/

1、更新linux

yum update

2、安装wget工具

yum install wget

3、使用wget下载MySQL Yum Repository并执行安装

wget https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
rpm -ivh mysql80-community-release-el7-7.noarch.rpm

4、在线安装MySQL8

//如果报错安装openssl-libs-1.0.2k-25.el7_9.x86_64.rpm
yum install -y mysql-server

6、修改vim /etc/my.cnf(存储地址、忽略大小写)

[client]
[client]
//这里的socket和mysqld中的socket路径一致,不然会报mysql8 ERROR 2002 (HY000)
socket=/var/lib/mysql/mysql.sock

[mysqld]
datadir=/u11/mysql/

default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
lower_case_table_names=1
skip-name-resolve

6、启动mysql服务

systemctl start mysqld

*****************如果出现错误

mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
1、关掉SELINUX
[root@192 mysql]# vi /etc/selinux/config
修改为:
# SELINUX=enforcing     # 注释掉
# SELINUXTYPE=targeted  #注释掉
SELINUX=disabled        #增加
2、使配置立即生效
[root@192 mysql]# setenforce 0

7、使用生成的临时密码登陆mysql,修改密码

grep 'temporary password' /var/log/mysqld.log
mysql -u root -p '密码'
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '输入root帐户密码';

8、开启远程登录

mysql> use mysql ;
mysql> update user set host = '%' where user = 'root';
mysql> FLUSH PRIVILEGES;

8、离线安装方式参考如下
https://blog.csdn.net/m0_51154284/article/details/127668847

你可能感兴趣的:(Linux,linux,mysql,服务器)