【MySQL】Linux下的MySQL8.0安装
Linux下的MySQL8.0安装
环境:Centos7
安装:MySQL-8.0.20
零、开始
本篇上接hadoop安装。
如果是为了装Hive,则所有操作都在hadoop集群master机器下完成。
本文所有输出都是在作者虚拟机上的输入得到的,输出因人而异,结果没问题就好。
一、安装MySQL
0、如果安装过MySQL(每个文件都要移除)
输入1(获取文件列表):rpm -qa | grep mysql
输出1:文件名列表
输入2(删除文件,文件名列表中的都要删除):yum remove 文件名
输出2:略
输入3(删除mysl配置文件):
rm -rf /var/lib/mysql
rm /etc/my.cnf
rm -rf /usr/share/mysql-8.0
输出3:略
1、查看自带数据库(输出与系统版本相关)
输入:rpm -qa | grep mariadb
输出:mariadb-libs-5.5.64-1.el7.x86_64
2、卸载自带数据库(数据库名以上条语句输出为准)
输入:rpm -e --nodeps mariadb-libs-5.5.64-1.el7.x86_64
输出:无
3、安装依赖
输入:yum install -y libaio perl net-tools
输出:略
4、下载mysql(下载目录自定,后面的地址见下图获取特定版本,下在windows里还要多几步,太麻烦)
输入:cd /root/coding/mysql
和wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar
输出:略
5、解压
输入:tar -xvf mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar
输出:
mysql-community-libs-8.0.20-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.20-1.el7.x86_64.rpm
mysql-community-test-8.0.20-1.el7.x86_64.rpm
mysql-community-common-8.0.20-1.el7.x86_64.rpm
mysql-community-devel-8.0.20-1.el7.x86_64.rpm
mysql-community-client-8.0.20-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.20-1.el7.x86_64.rpm
mysql-community-server-8.0.20-1.el7.x86_64.rpm
6、依次安装
输入:
rpm -ivh mysql-community-common-8.0.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.20-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.20-1.el7.x86_64.rpm
输出:略
二、启动MySQL
1、查看MySQL运行状态
输入:service mysqld status
输出(dead表示未启动):
2、启动MySQL
输入:service mysqld start
输出:Redirecting to /bin/systemctl start mysqld.service
关闭MySQL为:
service mysql stop
3、再次查看MySQL运行状态
输入:service mysqld status
输出:
4、查看临时密码(输出的"localhost: "后面就是临时密码【空格不算】)
输入:grep password /var/log/mysqld.log
输出:2020-05-10T13:01:50.320782Z 6 [Note] [MY-010454] [Server] A temporary password is generated for aaa@qq.com: Vs,FRbRkI0zT
5、使用临时密码登录MySQL
输入:mysql -uroot -p
和临时密码
输出:进入输入提示变为mysql>
退出输入
exit
6、修改密码(设为aaa@qq.com)
输入:alter user 'root'@'localhost' identified by 'aaa@qq.com';
输出:Query OK, 0 rows affected (0.00 sec)
默认不允许简单密码:包含大小写字母、数字和特殊符号,并且长度不能少于8位。
7、立即生效
输入:flush privileges;
输出:Query OK, 0 rows affected (0.00 sec)
三、MySQL远程访问
1、切换到mysql库
输入:use mysql
2、查看root用户的host属性
输入:select host,user from user;
输出:
+-----------+------------------+
| host | user |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+------------------+
4 rows in set (0.00 sec)
3、把第四个user为root的host改为"%":
输入:update user set host='%' where user='root';
和flush privileges;
输出:
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
此时再输入
select host,user from user;
,user为root的host应该为"%"。
4、在Navicat中链接MySQL(主机填虚拟机IP)
(全文完)