mysql 8 tcp6_MySQL8.0安装与配置

本文详细介绍了如何在Linux系统中下载、安装、配置MySQL 8.0,包括创建用户和组、解压安装包、设置权限、初始化数据库、配置my.cnf文件、启动MySQL服务,并解决TCP6监听问题,最后还涵盖了远程登录MySQL的步骤。
摘要由CSDN通过智能技术生成

一、下载MySQL

通过wget进行下载:

[root@iZwz9ba9y5k8ij7xf2boohZ software]#wget https://downloads.mysql.com/archives/get/p/23/file/ \

mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz

二、安装与配置

1、创建mysql用户和组

#创建MySQL用户

[root@iZwz9ba9y5k8ij7xf2boohZ software]#useradd mysql -s /sbin/nologin -M -g mysql

#创建MySQL组

[root@iZwz9ba9y5k8ij7xf2boohZ software]#groupadd mysql

2、解压

[root@iZwz9ba9y5k8ij7xf2boohZ software]#tar-xf mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz

3、安装

#1、重命名

[root@iZwz9ba9y5k8ij7xf2boohZ software]#mv mysql-8.0.13-linux-glibc2.12-x86_64 mysql

#2、拷贝到/usr/local下

[root@iZwz9ba9y5k8ij7xf2boohZ software]#mv mysql /usr/local/

#3、 进入到/usr/local/mysql目录下,进行授权

[root@iZwz9ba9y5k8ij7xf2boohZ mysql]#chown -R mysql:mysql ./

#4、初始化

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

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

注意:

不需要提前创建好data目录,否则会出现[ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting问题

会生成临时密码,记得保存

4、配置

my.cnf

进入到/usr/local/mysql/support-files目录中:

#1、创建my-default.cnf文件

[root@iZwz9ba9y5k8ij7xf2boohZ support-files]#touch my-default.cnf

#2、赋予文件权限

[root@iZwz9ba9y5k8ij7xf2boohZ support-files]#chmod 777 my-default.cnf

#3、将其覆盖/etc/my.cnf

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

#4、写入对应配置

[root@iZwz9ba9y5k8ij7xf2boohZ support-files]#vim /etc/my.cnf

vim /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

tmpdir= /tmp

port= 5186

#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

启动配置

#启动文件拷贝

[root@iZwz9ba9y5k8ij7xf2boohZ support-files]#cp mysql.server /etc/init.d/mysql#服务可执行权限

[root@iZwz9ba9y5k8ij7xf2boohZ support-files]#chmod +x /etc/init.d/mysql

5、启动MySQL

#启动MySQL

[root@iZwz9ba9y5k8ij7xf2boohZ support-files]#/etc/init.d/mysql start

Starting MySQL.Logging to '/usr/local/mysql/data/error.log'.

. [ OK ]#查看

[root@iZwz9ba9y5k8ij7xf2boohZ ~]#netstat -tunlp|grep 5186

tcp6 0 0 :::5186 :::* LISTEN 7249/mysqld

6、客户端环境变量配置

[root@iZwz9ba9y5k8ij7xf2boohZ bin]#echo 'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile

[root@iZwz9ba9y5k8ij7xf2boohZ bin]#source /etc/profile

7、修改密码

首先使用临时生成的密码进行登录,然后修改密码:

#登录

[root@iZwz9ba9y5k8ij7xf2boohZ bin]#mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ;or\g.

Your MySQL connection idis 8Server version:8.0.13

#修改密码

mysql> alter user 'root'@'localhost' identified by '********';

Query OK, 0 rows affected (0.08 sec)

此时,可以退出,再使用新密码进行登录了。

8、远程登录

mysql> select host,user frommysql.user;+-----------+------------------+

| host | user |

+-----------+------------------+

| localhost | mysql.infoschema |

| localhost | mysql.session |

| localhost | mysql.sys |

| localhost | root |

+-----------+------------------+

4 rows in set (0.00sec)

mysql> update mysql.user set host='%' where user='root';

Query OK,1 row affected (0.01sec)

Rows matched:1 Changed: 1Warnings: 0

mysql>flush privileges;

Query OK, 0 rows affected (0.00 sec)

参考:https://blog.csdn.net/atongmu2017/article/details/90610444

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值