Linux下安装mysql8.0.20

Linux下安装mysql8.0.20文章目录Linux下安装mysql8.0.20安装前准备安装Linux下安装mysql8.0.20安装前准备1.下载地址:2.检测是否安装过mysql#检测是否安装过mysqlrpm-qa|grepmysql#删除命令rpm-e–nodepsmysql-libs-5.1.73-5.el6_6.x86_643.查询所有Mysql对应的文件夹(删除)whereismysqlrm-rf/usr/lib64/mysql/usr/share/mysqlfin

大家好,又见面了,我是你们的朋友全栈君。

Linux下安装mysql8.0.20

安装前准备

1. 下载地址

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

2. 检测是否安装过mysql

# 检测是否安装过mysql
rpm -qa | grep mysql
# 删除命令
rpm -e --nodeps mysql-libs-5.1.73-5.el6_6.x86_64

3. 查询所有Mysql对应的文件夹(删除)

whereis mysql
rm -rf /usr/lib64/mysql /usr/share/mysql
find / -name mysql
rm -rf /etc/selinux/targeted/active/modules/100/mysql

在这里插入图片描述

4. 检查mysql用户组和用户是否存在,如果没有,则创建

cat /etc/group | grep mysql
cat /etc/passwd |grep mysql
groupadd mysql
useradd -r -g mysql mysql

在这里插入图片描述

安装

1. 下载、上传、解压安装包

官网下载,xftp上传

# 解压
tar -xvf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz

在这里插入图片描述

2. 将解压的文件移动到/usr/local下,并重命名为mysql

# 移动位置并重命名
mv /mysql-8.0.20-linux-glibc2.12-x86_64 /usr/local/mysql

在这里插入图片描述

3. 进入/usr/local/mysql目录下,创建data文件夹,并授权

cd /usr/local/mysql/
# 创建文件夹
mkdir data
# 给文件夹授权
chown -R root:root /usr/local/mysql
# 给文件夹授权
chown -R mysql:mysql /usr/local/mysql/data/

在这里插入图片描述

4. 初始化数据库,并会自动生成随机密码,记下等下登陆要用

# 初始化数据库,mysql的bin目录下的mysqld命令
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

临时密码:root@localhost:后面的那串代码
在这里插入图片描述
补充说明:
此步可能会出错:

出现该问题首先检查该链接库文件有没有安装使用,命令进行核查。
并安装文件,安装完成之后重新初始化。

# 检测命令
rpm -qa|grep libaio
# 
yum install  libaio-devel.x86_64
# 
yum -y install numactl

在这里插入图片描述

5. cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

复制过去,其实也就是空白页,一开始没有my-default.cnf这个文件,可以用touch my-default.cnf命令创建一个,并配置权限

chmod 777 ./my-default.cnf 

在这里插入图片描述

6. 配置my.cnf

vi /etc/my.cnf
[mysqld]
 
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
 
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
 
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /tmp/mysql.sock
log-error = /usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
port = 3306
#lower_case_table_names = 1
# server_id = .....
# socket = .....
#lower_case_table_names = 1
max_allowed_packet=32M
default-authentication-plugin = mysql_native_password
#lower_case_file_system = on
#lower_case_table_names = 1
log_bin_trust_function_creators = ON
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 
 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

如果后期mysql运行报错,可以直接到log-error = /usr/local/mysql/data/error.log目录下直接查看错误日志
命令:cat /usr/local/mysql/data/error.log

7. 开机自启,进入/usr/local/mysql/support-files进行设置

cd support-files/
cp mysql.server /etc/init.d/mysql 
chmod +x /etc/init.d/mysql

在这里插入图片描述

8. 注册服务并检测

  • 注册
chkconfig --add mysql

如果命令没有,在需要处理chkconfig

rpm -aq |grep chkconfig
export PATH=/sbin:$PATH
chkconfig
echo $PATH
PATH="$PATH":/sbin
echo $PATH
  • 检测
chkconfig --list mysql

在这里插入图片描述

9. etc/ld.so.conf要配置路径,不然报错

vim /etc/ld.so.conf
 
# 添加如下内容:
/usr/local/mysql/lib

在这里插入图片描述

10. 配置环境变量

# 配置环境变量
vim /etc/profile

# 添加如下内容:
# MYSQL ENVIRONMENT
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib

# 系统重新加载文件,记得一定要
source /etc/profile

在这里插入图片描述

11. 登陆,修改密码

密码:第4步初始化数据库随机生成得密码,输入密码不显示。

[root@VM_0_3_centos support-files]# service mysql start
Starting MySQL.. SUCCESS! 
[root@VM_0_3_centos support-files]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 82
Server version: 8.0.20

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> alter user 'root'@'localhost' identified by 'kid+1412';
Query OK, 0 rows affected (0.01 sec)

mysql> 

在这里插入图片描述

12. 开启Navicat远程连接

# 登录
[root@VM_0_3_centos support-files]# mysql -uroot -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2582
Server version: 8.0.20 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# 选择mysql数据库
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
# 查看用户信息
mysql> select host, user, authentication_string, plugin from user;
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| host      | user             | authentication_string                                                  | plugin                |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.session    | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.sys        | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | root             | $A$005$=!..iRO=k:x_>qiFtXTYJmwgur/2pJH1mfk26FBL.1YZOC.YcBw8auuFFM0 | caching_sha2_password |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
4 rows in set (0.00 sec)
# 更新root信息
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0
# 授权root用户可以远程登陆,失败
mysql> GRANT ALL ON *.* TO 'root'@'%';
ERROR 1410 (42000): You are not allowed to create a user with GRANT
# 立即生效,重新授权
mysql> flush privileges; 
Query OK, 0 rows affected (0.02 sec)
# 授权root用户可以远程登陆
mysql> GRANT ALL ON *.* TO 'root'@'%';
Query OK, 0 rows affected (0.02 sec)
# 立即生效
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
# 
mysql> alter user 'root'@'%' identified with mysql_native_password by 'kid+1412';
Query OK, 0 rows affected (0.01 sec)
# 立即生效
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
# 退出
mysql> exit
Bye

13.navicat连接成功

在这里插入图片描述

Mysql8.0.20 创建用户并授权

https://blog.csdn.net/qq_37040886/article/details/107300838

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/133375.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • VS中时间控件的使用[通俗易懂]

    VS中时间控件的使用[通俗易懂]使用方法:1.下载时间控件 My97DatePickerBeta.2.在VS中新建项目,添加web窗体。3.将下载好的文件导入你的项目文件中,然后添加如下代码: <scriptsrc="Content/My97DatePickerBeta/WdatePicker.js"type="text/javascript"></script>//引号内为Wdat…

    2022年5月24日
    132
  • 医疗用户端app原型/问诊/挂号/开药/视频问诊/电子处方/预约/互联网医疗平台用户端/Axure原型/电话问诊/药品/就诊开药/远程医疗平台/线上问诊/线上看病/rp源文件/移动端医疗原型/门诊「建议收藏」

    医疗用户端app原型/问诊/挂号/开药/视频问诊/电子处方/预约/互联网医疗平台用户端/Axure原型/电话问诊/药品/就诊开药/远程医疗平台/线上问诊/线上看病/rp源文件/移动端医疗原型/门诊「建议收藏」医疗用户端app原型/问诊/挂号/开药/视频问诊/电子处方/预约/互联网医疗平台用户端/Axure原型/电话问诊/药品/就诊开药/远程医疗平台/线上问诊/线上看病/rp源文件/移动端医疗原型Axure原型演示地址:https://www.pmdaniu.com/storages/124091/e51ce895d0be36e758d8fbcebc67f6ef-93733/start.html#g=1&p=%E9%A6%96%E9%A1%B5【医药、医疗】互联网医疗平台(问诊+挂号+开药)-用户

    2022年6月16日
    32
  • 1442. 形成两个异或相等数组的三元组数目[通俗易懂]

    1442. 形成两个异或相等数组的三元组数目[通俗易懂]给你一个整数数组 arr 。现需要从数组中取三个下标 i、j 和 k ,其中 (0 <= i < j <= k < arr.length) 。a 和 b 定义如下:a = arr[i] ^ arr[i + 1] ^ … ^ arr[j – 1]b = arr[j] ^ arr[j + 1] ^ … ^ arr[k]注意:^ 表示 按位异或 操作。请返回能够令 a == b 成立的三元组 (i, j , k) 的数目。示例 1:输入:arr = [2,3,1,6,7]

    2022年8月9日
    6
  • javascript_JavaScript走向成熟

    javascript_JavaScript走向成熟javascript明年JavaScript将有20年的历史(从首次在Netscape浏览器中首次亮相开始算起)。这是一门具有悠久历史的语言,并且从其早期开始就带来了很多负担,但是随着它离开少年时代的到来,我认为这是一种最终发展起来的语言。JavaScript通过允许脚本在浏览器中运行来彻底改变了Web。但是,在最初流行之后,它很快就开始受到不良声誉,并且经常与编写不良,剪切粘贴的代码…

    2022年7月13日
    18
  • mybatis date转string_mybatis字符串转日期

    mybatis date转string_mybatis字符串转日期mybatismysql时间字符串转date(查询)andcreate_time<=str_to_date(#{createTime},’%Y-%m-%d%H:%i:%s’)andDATE_FORMAT(create_time,’%Y-%m-%d%H:%i:%s’)>=DATE_FORMAT(#{queryStartTime},’%Y-%m-%d%H:%i:%s’)andcreate_time>=DATE_FORMAT(#{queryStart

    2022年9月28日
    2
  • go语言 ssh_websshpro

    go语言 ssh_websshprogowebssh推荐使用文章目录gowebssh推荐使用1.前言2.项目地址3.简单修改4.交叉编译5.结果展示1.前言一般ssh的登录使用需要ssh客户端进行登录,比如xshell、putty等,之前我们也推荐过九款:https://blog.csdn.net/weixin_39510813/article/details/118722265。目前我们有一个需求是在web上登录设备的ssh,一番搜索后找到一个比较小巧合适的,并且做了一点简单的修改,基于go+vue的,最后可以打

    2025年6月2日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号