linux mysql8.0二进制部署安装
2022/6/30 2:49:55
本文主要是介绍linux mysql8.0二进制部署安装,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
二进制部署8版本:
卸载mariadb软件:
[root@mysql ~]# rpm -qa |grep mariadb mariadb-libs-5.5.56-2.el7.x86_64 [root@mysql ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
解压二进制包:
[root@mysql ~]# wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz [root@mysql ~]# tar -xf mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz -C /usr/local [root@mysql ~]# mv /usr/local/mysql-8.0.16-linux-glibc2.12-x86_64 /usr/local/mysql-8.0.16 [root@mysql ~]# mkdir /usr/local/mysql-8.0.16/{data,logs} [root@mysql ~]# touch /usr/local/mysql-8.0.16/logs/mysql.log
创建mysql用户:
[root@mysql ~]# groupadd mysql [root@mysql ~]# useradd mysql -g mysql [root@mysql ~]# chown -R mysql.mysql /usr/local/mysql-8.0.16
初始化数据:
# 加上--initialize参数是开启临时密码、安全策略(密码过期时间)------------(当前使用为无密码、无安全策略) [root@mysql ~]# /usr/local/mysql-8.0.16/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql-8.0.16 --datadir=/usr/local/mysql-8.0.16/data
添加配置文件:
[root@mysql ~]# vim /etc/my.cnf [mysqld] server_id=1 user=mysql port=3306 bind-address=0.0.0.0 basedir=/usr/local/mysql-8.0.16 datadir=/usr/local/mysql-8.0.16/data socket=/tmp/mysql.sock log_error=/usr/local/mysql-8.0.16/logs/mysql.log [mysql] socket=/tmp/mysql.sock
启动MySQL-8.0服务:
[root@mysql ~]# cp -a /usr/local/mysql-8.0.16/support-files/mysql.server /etc/init.d/mysqld [root@mysql ~]# /etc/init.d/mysqld start Starting MySQL.Logging to '/usr/local/mysql-8.0.16/data/mysql.err'. .. SUCCESS! 或者--------------------------------------------------------------------------------------------- [root@mysql ~]# vim /etc/systemd/system/mysqld.service [Unit] Description=MySQL Server Documentation=man:mysqld(8) Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql ExecStart=/usr/local/mysql-8.0.16/bin/mysqld --defaults-file=/etc/my.cnf LimitNOFILE = 5000 [root@mysql ~]# systemctl start mysqld.service [root@mysql ~]# systemctl enable mysqld.service Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /etc/systemd/system/mysqld.service. [root@mysql ~]# netstat -tunpl |grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1232/mysqld tcp6 0 0 :::33060 :::* LISTEN 1232/mysqld
添加mysql环境变量:
[root@mysql ~]# echo 'export PATH=/usr/local/mysql-8.0.16/bin:$PATH' >> /etc/profile [root@mysql ~]# source /etc/profile
修改root随机密码:
[root@mysql ~]# mysql mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.16 Copyright (c) 2000, 2019, 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 '123456';
[root@mysql ~]# mysql -uroot -p123456 -e "select @@version;" 2>/dev/null +-----------+ | @@version | +-----------+ | 8.0.16 | +-----------+
这篇关于linux mysql8.0二进制部署安装的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-20MySQL集群部署教程:入门级详解
- 2024-11-20MySQL集群教程:入门与实践指南
- 2024-11-20部署MySQL集群教程:新手入门指南
- 2024-11-20MySQL读写分离教程:轻松入门
- 2024-11-20部署MySQL集群入门:一步一步搭建你的数据库集群
- 2024-11-19部署MySQL集群学习:入门教程
- 2024-11-19如何部署MySQL集群:新手入门教程
- 2024-11-19Mysql安装教程:新手必看的详细安装指南
- 2024-11-18Mysql安装入门:新手必读指南
- 2024-11-18MySQL事务MVCC原理入门详解