linux安装mysql菜鸟教程_Linux安装mysql教程
安装之前需要先卸载mysql
1.1、下载压缩包
1 [root@guohaien package]#wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
其中下载地址的获取方法如下所示
2、按下图所示的步骤点击
3、右键下图标记位置,复制下载地址
1.2、给mysql目录创建一个用户组和用户,并在mysql目录下创建一个data目录,具体的操作如下所示
1 [root@guohaien soft]#groupadd mysql
2 [root@guohaien soft]#useradd -g mysql -d /soft/mysql mysql
3 [root@guohaien soft]#cd mysql
4 [root@guohaien mysql]#mkdir data
1.3、先解压包,后进入文件夹mysql-5.7.25-linux-glibc2.12-x86_64,将里面的内容移动到上面创建的mysql目录下,并删除该文件夹,最后进入到mysql目录中,具体的操作顺序如下所示
1 [root@guohaien package]#tar zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
2 [root@guohaien package]#cd mysql-5.7.25-linux-glibc2.12-x86_64
3 [root@guohaien mysql-5.7.25-linux-glibc2.12-x86_64]#mv * /soft/mysql
4 [root@guohaien mysql-5.7.25-linux-glibc2.12-x86_64]#cd ..
5 [root@guohaien package]#rm -rf mysql-5.7.25-linux-glibc2.12-x86_64
6 [root@guohaien package]#cd ../mysql
1.4、初始化数据库,初始化的时候会生成一个随机密码,需要记录下来,后面会用到,其中密码在如下图标志的位置
初始化是可能会出现以下问题
其中一种输出是如下所示
./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
这是因为没有安装libaio,只需要执行如下命令即可
1 [root@guohaien mysql]#yum install -y libaio
还有可能输出如下结果,这是因为data目录不为空,只需要进入到data目录执行rm -rf *
2019-03-19T06:04:15.345713Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation formore details).2019-03-19T06:04:15.347456Z 0 [ERROR] --initialize specified but the data directory has files init. Aborting.2019-03-19T06:04:15.347485Z 0 [ERROR] Aborting
1.5、修改mysql.server文件中的basedir和datadir的值,一下是修改文件的命令,和修改的位置
1 [root@guohaien mysql]#vim support-files/mysql.server
修改完成按Esc,然后输入wq退出
1.6、创建配置文件
给默认的my.cnf文件备份
1 [root@guohaien mysql]#cp /etc/my.cnf /etc/my.cnf.bak
可以将my.cnf文件修改为如下所示
[mysqld]
basedir=/soft/mysql
datadir=/soft/mysql/data
character_set_server=utf8
init_connect='SET NAMES utf8'
[client]default-character-set=utf8
1.7、启动mysql服务
[root@guohaien mysql]#./support-files/mysql.server start
若输出以上结果则启动成功
可以通过如下步骤改变启动的方法,并设置为开机自启动
1 [root@guohaien mysql]#cp support-files/mysql.server /etc/init.d/mysqld
2 [root@guohaien mysql]#systemctl enable mysqld
3 mysqld.service is not a native service, redirecting to /sbin/chkconfig.4 Executing /sbin/chkconfig mysqld on
修改后的mysql服务的启动命令有两种为
[root@guohaien mysql]#service mysqld start
[root@guohaien mysql]#systemctl start mysqld
其中关闭和重启服务只需要将start改为stop和restart即可
1.8、修改登录密码
[root@guohaien mysql]#./bin/mysqladmin -u root -p password
Enter password:
New password:
Confirm new password:
Warning: Since password will be sent to serverin plain text, use ssl connection to ensure password safety.
先输入原始密码,在输入两次新密码(其中原始密码即为上面生成的那个随机密码)
也可以使用如下命令修改密码
1 [root@guohaien mysql]#./bin/mysqladmin -uroot -p'原始密码' password '新密码'
设置完成后就能使用新密码登录数据库
1 [root@guohaien mysql]#./bin/mysql -u root -p
2 Enter password:3 Welcome to the MySQL monitor. Commands endwith ; or g.4 Your MySQL connection id is 4
5 Server version: 5.7.25MySQL Community Server (GPL)6
7 Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.8
9 Oracle is a registered trademark of Oracle Corporation and/or its10 affiliates. Other names may be trademarks of their respective11 owners.12
13 Type 'help;' or 'h' forhelp. Type 'c' to clear the current input statement.14
15 mysql>
可以给登录服务创建一个软链接
[root@guohaien mysql]#ln -s /soft/mysql/bin/mysql /usr/bin/mysql
这样就能将上面的./bin/mysql 替换为mysql
1.9、mysql远程授权
目前只能在该服务器上登录mysql,远程并不能访问,登录mysql后执行如下sql
mysql> grant all privileges on *.* to 'root'@'%' identified by '密码';
Query OK,0 rows affected, 1 warning (0.00sec)
mysql> FLUSH PRIVILEGES;
Query OK,0 rows affected (0.00 sec)
以上即为mysql5.7在centos7.6 64位系统下的安装及配置
2.1、关闭mysql服务
1 [root@guohaien /]#service mysqld stop
2.2、检查是否有rpm包,若是没有用rpm安装过mysql,应该就没有,若是有的话就要删除
检查的命令
1 [root@guohaien /]#rpm -qa|grep -i mysql
删除的命令
1 [root@guohaien /]#rpm -e 包名
有时候会有依赖无法删除,可以用命令
1 root@guohaien /]#rpm -e --nodeps 包名
2.3、检查是否有mysql相关目录或文件,若有则删除
检查的命令
1 [root@guohaien /]#find / -name mysql
删除的命令
1 [root@guohaien /]#rm -rf 目录或文件
2.4、删除mysql用户和分组
删除用户命令
1 [root@guohaien /]#userdel mysql
删除分组命令
1 [root@guohaien /]#groupdel mysql
卸载完成后就可以开始安装mysql
linux安装mysql菜鸟教程_Linux安装mysql教程相关推荐
- linux上mysql卸数_Linux下MySQL卸载和安装图文教程
Linux下MySQL卸载和安装图文教程 发布时间:2020-09-02 08:43:17 来源:脚本之家 阅读:59 作者:伊宇紫 第一次写博客,做了两年的开发,工作之余给自己找点有意义的事做,分享 ...
- linux下mysql5.7的安装教程_linux下mysql 5.7.18安装教程 邯郸
1.新建用户和组 groupadd -g 500 mysql useradd -g 500 -u 500 -d /dev/null -s /sbin/nologin -M mysql 2.下载 cd ...
- linux下mysql目录结构_linux下mysql安装配置与目录结构
本节内容: linux下mysql安装与配置.mysql目录结构. 1.准备安装程序(官方网站下载) 服务端:MySQL-server-community-5.1.44-1.rhel4.i386.rp ...
- linux查看 mysql 登陆 失败_Linux安装完mysql后提示错误无法登陆mysql怎么办?
mysql是数据库,用于管理系统的数据,使用非常广泛,Linux系统操作中,在安装完mysql后提示错误,导致用户无法登陆,遇到这种情况该怎么办呢?下面小编就给大家介绍下Linux无法登陆mysql的 ...
- linux mysql 装哪里_linux 下 mysql 安装目录在哪里
linux 下 mysql 安装目录在哪里.linux mysql 安装介绍: linux 服务器 RedHat 5.0.server. MySQL 版本: 下载地址链接:http://dev.mys ...
- linux mysql 目录结构图_linux下mysql安装、目录结构、配置
1.准备安装程序(官方网站下载) 服务端:MySQL-server-community-5.1.44-1.rhel4.i386.rpm 客户端:MySQL-client-community-5.1.4 ...
- linux下mysql目录结构_linux下mysql安装、目录结构、配置
1.准备安装程序(官方网站下载) 服务端:MySQL-server-community-5.1.44-1.rhel4.i386.rpm 客户端:MySQL-client-community-5.1.4 ...
- dev可以运行mysql文件夹_Linux查看mysql 安装路径和运行路径
一.查看文件安装路径 由于软件安装的地方不止一个地方,所有先说查看文件安装的所有路径(地址). 这里以mysql为例.比如说我安装了mysql,但是不知道文件都安装在哪些地方.放在哪些文件夹里,可以用 ...
- 安装mysql5 1步骤_Linux系统安装MySQL详细步骤(mysql-5.1等)
第一步.查找以前是否安装有mysql 使用下面命令:rpm -qa|grep -i mysql 如果显示有包则说明已安装mysql 第二步.如果已安装,则需要删除已安装的数据库 可按以下步骤删除数据库 ...
- crt安装mysql安装包_Linux安装MySQL步骤
1. 通过secureCRT工具连接Linux系统 2. 上传 mysql 的安装包 alt + p -------> put d:/setup/mysql-5.7.27-1.el7.x86_6 ...
最新文章
- 汇总|3D目标检测文章(CVPR2020)
- android程序贴吧,【Android 教程总结贴】归纳所有android贴
- 利用logistic回归构建申请信用评级案例
- 手动删除3389连接记录
- oracle导入时 ora39166,impdp ORA-39002,ORA-39166,ORA-39164的问题及解决
- 如何打造“智能助理”?阿里对话开发平台这样做
- python装饰器执行顺序
- mysql command line client闪一下消失
- 可以批量转modis投影_SNAP批量处理Sentinel2数据
- 认清业务、技术与软件系统的价值链
- 12C 新特性 | 标量子查询自动转换
- 基于Kinect 2.0深度摄像头的三维重建 and Kinect Fusion
- 实用免费的SNMP网管工具-sugarnmsTool
- 当AI邂逅电能:与图知科技一起探索工业AI王座|白洞战报
- 关于“Windows无法验证设备所需的驱动程序的数字签名”错误的解决方法
- 个人官网第8次升级(新功能、用户体验、修复bug、系统优化)
- STM32F103时钟系统
- BAPI 创建343物料凭证
- ajax thinkphp配合ajax的简单列子
- Android开发笔记(序)