CentOS7安装MySQL5.6

1.安装包准备(MySQL官网下载

(1)查看MySQL是否安装,如果存在就先卸载

[root@hadoop101 桌面]# rpm -qa|grep MySQL
mysql-libs-5.1.73-7.el6.x86_64
[root@hadoop101 桌面]# rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64

(2)查看mariadb是否安装,如果存在就先卸载

[root@hadoop1 mysql-libs]# rpm -qa|grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
[root@hadoop1 mysql-libs]# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

(3)上传mysql-libs.zip到hadoop102的/opt/software目录,并解压文件到当前目录

复制代码
[root@hadoop1 mysql-libs]# cd /opt/software
[root@hadoop1 software]# ll
total 75988
-rw-r--r--. 1 root root 77807942 Aug 13 12:17 mysql-libs.zip
[root@hadoop1 software]# unzip mysql-libs.zip 
Archive:  mysql-libs.zip
   creating: mysql-libs/
  inflating: mysql-libs/MySQL-client-5.6.24-1.el6.x86_64.rpm  
  inflating: mysql-libs/mysql-connector-java-5.1.27.tar.gz  
  inflating: mysql-libs/MySQL-server-5.6.24-1.el6.x86_64.rpm  
[root@hadoop1 software]# ll
total 75992
drwxr-xr-x. 2 root root     4096 Jun 26  2015 mysql-libs
-rw-r--r--. 1 root root 77807942 Aug 13 12:17 mysql-libs.zip
复制代码

(4)进入到mysql-libs文件夹下

[root@hadoop1 software]# cd mysql-libs/
[root@hadoop1 mysql-libs]# ll
total 76048
-rw-r--r--. 1 root root 18509960 Mar 26  2015 MySQL-client-5.6.24-1.el6.x86_64.rpm
-rw-r--r--. 1 root root  3575135 Dec  1  2013 mysql-connector-java-5.1.27.tar.gz
-rw-r--r--. 1 root root 55782196 Mar 26  2015 MySQL-server-5.6.24-1.el6.x86_64.rpm

2.安装MySQL服务器

(1)安装MySQL服务端

[root@hadoop101 mysql-libs]# rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm

(2)查看产生的随机密码

[root@hadoop101 mysql-libs]# cat /root/.mysql_secret
OEXaQuS8IWkG19Xs

(3)查看MySQL状态

[root@hadoop101 mysql-libs]# service mysql status

(4)启动MySQL

[root@hadoop101 mysql-libs]# service mysql start

3.安装MySQL客户端

(1)安装MySQL客户端

[root@hadoop101 mysql-libs]# rpm -ivh MySQL-client-5.6.24-1.el6.x86_64.rpm

(2)链接MySQL(密码替换成产生的随机密码)

[root@hadoop101 mysql-libs]# mysql -uroot -pOEXaQuS8IWkG19Xs

(3)修改密码('000000'替换成你设置的密码)

mysql>SET PASSWORD=PASSWORD('000000');

(4)退出MySQL

mysql>exit

4.MySQL中user表中主机配置

配置只要是root用户+密码,在任何主机上都能登录MySQL数据库。

(1)进入MySQL

[root@hadoop101 mysql-libs]# mysql -uroot -p000000

(2)显示数据库

mysql>show databases;

(3)使用MySQL数据库

mysql>use mysql;

(4)展示MySQL数据库中的所有表

mysql>show tables;

(5)展示user表的结构

mysql>desc user;

(6)查询user表

mysql>select User, Host, Password from user;

(7)修改user表,把Host表内容修改为%

mysql>update user set host='%' where host='localhost';

(8)删除root用户的其他host

mysql>

delete from user where Host='hadoop101';

delete from user where Host='127.0.0.1';

delete from user where Host='::1';

(9)刷新

mysql>flush privileges;

(10)退出

mysql>quit;

 

linux下,MySQL默认的数据文档存储目录为/var/lib/mysql

 

参考:https://www.jianshu.com/p/98b6c1cbcb50

posted @   猫不夜行  阅读(1836)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示