Linux - Mysql8.0.18下载到安装 启动

1.下载mysql

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

 

~] cd /usr/local

~] wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz

~] tar xvf mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz

~] mv mysql-8.0.18-linux-glibc2.12-x86_64 mysql

~] rm -rf mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz

----- 新建mysql用户、组及目录、数据仓库目录

~] groupadd mysql

~] useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql

~] cd /usr/local/mysql

~] chown -R mysql .

~] chgrp -R mysql .

~] mkdir /data/mysql

~] chown -R mysql /data/mysql

----- 开始配置参数

 

~] bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

If Error:

bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

检查该链接库文件有没有安装使用:

~] rpm -qa|grep libaio

命令运行后系统中无该链接库文件,安装

~] yum install  libaio-devel.x86_64

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

2019-12-27T03:12:51.138272Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: r7l<MlxQ9+LJ

~] bin/mysql_ssl_rsa_setup  --datadir=/data/mysql

-- 要先记住上面返回的临时密码哈:r7l<MlxQ9+LJ

----- 修改系统配置文件

~] vi /etc/my.cnf

[mysqld]

basedir=/usr/local/mysql

datadir=/data/mysql

socket=/tmp/mysql.sock

----- 添加Mysql到系统服务

~] cp -a ./support-files/mysql.server /etc/init.d/mysql

~] chmod +x /etc/init.d/mysql

~] chkconfig --add mysql

~] chkconfig --list mysql # 检查是否生效

---------- 启动Mysql

~] service mysql start

Starting MySQL... [ OK ]

----- 软链个bin/mysql

~] ln -s /usr/local/mysql/bin/mysql /usr/bin/

 

----- 登陆

~] mysql -uroot -p

Enter password:

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

Your MySQL connection id is 9

Server version: 8.0.18

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 WITH mysql_native_password BY 'ABCD!!1234a';

 

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

If Error:

Starting MySQL...... mysqld_safe error: log-error set to '/var/log/mari.....

~] mkdir /var/log/mariadb/ && touch /var/log/mariadb/mariadb.log

~] chown -R mysql:mysql /var/log/mariadb/

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

启动 : service mysql start

查看 : service mysql status

重启 : service mysql reload / restart

停止 : service mysql stop

 

 

----- 配置外部连接

my.cnf 下增加 mysqld

default_authentication_plugin=mysql_native_password

--- 设置root账户的host地址

~> use mysql

~> update user set host ='%' where user='root';

##~> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'ABCD!!1234a';

~> FLUSH PRIVILEGES;

 

 

 

 

mysql8安装包以及安装说明,在centeros7下的安装.解压缩后会有两个文件:mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar和mysql8安装说明.txt 1、安装 rpm -i 需要安装的包文件名 举例如下: rpm -i example.rpm 安装 example.rpm 包; rpm -iv example.rpm 安装 example.rpm 包并在安装过程中显示正在安装的文件信息; rpm -ivh example.rpm 安装 example.rpm 包并在安装过程中显示正在安装的文件信息及安装进度; 2、查看安装完成的软件 rpm -qa | grep mysql mysql-community-libs-5.7.24-1.el7.x86_64 mysql-community-common-5.7.24-1.el7.x86_64 mysql-community-client-5.7.24-1.el7.x86_64 mysql-community-server-5.7.24-1.el7.x86_64 3、卸载软件 rpm -e --nodeps 要卸载的软件包 rpm -e --nodeps mysql-community-libs-5.7.24-1.el7.x86_64 rpm -e --nodeps mysql-community-common-5.7.24-1.el7.x86_64 rpm -e --nodeps mysql-community-client-5.7.24-1.el7.x86_64 rpm -e --nodeps mysql-community-server-5.7.24-1.el7.x86_64 看看系统中有没有自带有mysql的东西,有就先删除掉。 查看: find / -name mysql 删除: rm -rf 上边查找到的路径,多个路径用空格隔开 #或者下边一条命令即可 find / -name mysql|xargs rm -rf; mkdir -p /usr/local/mysql8 cd /usr/local/mysql8 ll 将下载的资源包(mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar)上传到 usr/local/mysql8 目录下,并解压 tar -xvf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar 依次安装 rpm -ivh mysql-community-common-8.0.15-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm 查看已安装资源 rpm -qa | grep mysql groupadd mysql useradd -g mysql mysql mysqld --initialize 初始化 chown mysql:mysql /var/lib/mysql -R 授权 systemctl start mysqld 开启mysql服务 systemctl status mysqld 查看mysql 状态 cat /var/log/mysqld.log | grep password 查看root初始密码 使用root用户登录mysql ,并修改root用户密码 mysql -u root -p #回车之后输入前面的初始密码也就是 XXXXXX(填自己的密码) ALTER USER "root"@"localhost" IDENTIFIED BY "自己的密码"; FLUSH PRIVILEGES; #立即生效 再次用户root 用户登录 输入自己刚刚修改的密码就可以了 远程连接 use mysql; update user set host = '%' where user ='root'; ALTER USER 'root'@'%' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #更改加密方式 ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '自己的密码'; #更新用户密码 (我这里为root )
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黑漆#000000

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值