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 |
+-----------+
标签:8.0,16,二进制,local,linux,mysql8.0,usr,mysql,root 来源: https://www.cnblogs.com/chenlifan/p/16424409.html