mysql linux 插件安装方法_linux下安装mysql8.0.x步骤

本文详细介绍了在Linux系统中安装MySQL8.0.x的步骤,包括下载MySQL,解压重命名,创建数据目录,设置用户组和用户,初始化数据库,配置my.cnf,设置环境变量,解决启动过程中遇到的各种错误,以及如何进行基本操作和防火墙设置,确保MySQL服务正常运行。
摘要由CSDN通过智能技术生成

1.下载mysql

b83ce53a13d292d30599df85d924196b.png

5ecba366aedae62dc1cd3cf0a5db53de.png

将下载的mysql上传打linux

2.解压并重命名

[root@rsyncClient local]# tar -zxvf mysql-8.0.18-el7-x86_64.tar.gz -C /usr/local/[root@rsyncClient local]# mv mysql-8.0.18-el7-x86_64/ mysql

3.在mysql根目录下创建data目录,存放数据

[root@rsyncClientopt]# cd /usr/local/mysql/[root@rsyncClient mysql]# mkdir data

4.创建mysql用户组和mysql用户

[root@rsyncClient local]# groupadd mysql

[root@rsyncClient local]# useradd-g mysql mysql

5.改变mysql目录权限

[root@rsyncClient local]# chown -R mysql.mysql /usr/local/mysql/

6.初始化数据库

[root@rsyncClient mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql

--datadir=/usr/local/mysql/data

428a2d8ae9196aa3fd6f6907d71f4260.png

7.配置mysql

在mysql/support-files创建文件my-default.cnf

[root@rsyncClient support-files]# cd /usr/local/mysql/support-files/[root@rsyncClient support-files]# touch my-default.cnf

复制配置文件到/etc/my.cnf

[root@rsyncClient support-files]# cp -a ./my-default.cnf /etc/my.cnf

cp: overwrite ‘/etc/my.cnf’? y

编辑my.cnf

[client]

port=3306socket=/tmp/mysql.sock

[mysqld]

port=3306user=mysql

socket=/tmp/mysql.sock

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

8.配置环境变量

编辑 / etc/profile 文件

[root@rsyncClient mysql]# vim /etc/profile

#配置mysql环境变量

PATH=/data/mysql/bin:/data/mysql/lib:$PATH

export PATH

#让其生效

[root@rsyncClient mysql]# source/etc/profile

#看环境变量是否生效

[root@rsyncClient mysql]# echo $PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

9.启动mysql

[root@rsyncClient mysql]# systemctl start mysqld

启动失败报错1:

Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

解决方案:

[root@rsyncClient ~]# chown mysql:mysql -R /usr/local/mysql/

启动失败报错2:

[root@rsyncClient mysql]# service mysql start/etc/init.d/mysql: ./bin/my_print_defaults: /lib/ld-linux.so.2: bad ELF interpreter: No such file or

directory Starting MySQL. ERROR! The server quit without

updating PID file (/var/lib/mysql/rsyncClient.pid).

去这个目录下面查看 cat/usr/local/mysql/data/rsyncClient.err错误,对应的的解决,这里错误是因为my.conf配置错误

启动失败报错3:

mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file:

No such file or directory

[root@rsyncClient init.d]# yum install libncurses.so.5

以这个为例,如果缺少这样依赖,直接用yum安装

启动失败报错4:

[root@rsyncClient data]# mysql -uroot -p

Enter password:

ERROR2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded:

/usr/lib/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory

身份验证插件不能加载

解决办法:

[root@rsyncClient lib]# vim /etc/my.cnf

在这个[mysqld]下添加一行:

default_authentication_plugin=mysql_native_password

如果忘记了密码在加上:

skip-grant-tables(跳过密码验证)等设置了密码就去掉

10 使用systemctl命令启动关闭mysql服务

启动mysql服务:

#systemctl start mysqld.service

停止mysql服务

#systemctl stop mysqld.service

重启mysql服务

#systemctl restart mysqld.service

查看mysql服务当前状态

#systemctl status mysqld.service

设置mysql服务开机自启动

#systemctl enable mysqld.service

停止mysql服务开机自启动

#systemctl disable mysqld.service

11.mysql的基本操作

# 使用mysql客户端连接mysql

12.防火墙问题

[root@rsyncClient data]# firewall-cmd --permanent --zone=public --add-port=3306/tcp #允许访问

success

[root@rsyncClient data]# firewall-cmd --reload #重新加载

success

[root@rsyncClient data]# firewall-cmd --permanent --zone=public --query-port=3306/tcp  #查看是否开通访问权限

yes

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值