1:下载

[root@localhost soft]# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz

2:解压文件

[root@dbserver /]# tar -xzvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

3修改文件

[root@dbserver local]# mv  mysql-5.7.19-linux-glibc2.12-x86_64 mysql

4:检查库文件是否有删除,若有便删除(linux系统自带的)

    [root@dbserver mysql]# rpm -qa | grep mysql
  删除
   [root@dbserver mysql]# rm -e –-nodeps mysql-libs-5.1.52.x86_64

5:检查mysql组和用户是否存在,如无创建

      [root@dbserver ~]# cat /etc/group | grep mysql[root@dbserver ~]# cat /etc/passwd |grep mysql

创建

    [root@dbserver ~]#groupadd mysql[root@dbserver ~]#useradd -r -g mysql mysql//useradd -r参数表示mysql用户是系统用户,不可用于登录系统

6:在mysql下添加data目录

      [root@dbserver mysql]# mkdir data

7:更改mysql目录下所有的目录及文件夹所属组合用户

[root@dbserver mysql]# cd /usr/local/
[root@dbserver local]# chown -R mysql mysql/
[root@dbserver local]# chgrp -R mysql mysql/
[root@dbserver local]# cd mysql/
[root@dbserver mysql]# ls -l
total 40
drwxr-xr-x.  2 mysql mysql  4096 Aug 31 16:45 bin
-rw-r--r--.  1 mysql mysql 17987 Jun 22 22:13 COPYING
drwxr-xr-x.  2 mysql mysql     6 Aug 31 16:48 data
drwxr-xr-x.  2 mysql mysql    52 Aug 31 16:45 docs
drwxr-xr-x.  3 mysql mysql  4096 Aug 31 16:44 include
drwxr-xr-x.  5 mysql mysql  4096 Aug 31 16:45 lib
drwxr-xr-x.  4 mysql mysql    28 Aug 31 16:45 man
-rw-r--r--.  1 mysql mysql  2478 Jun 22 22:13 README
drwxr-xr-x. 28 mysql mysql  4096 Aug 31 16:45 share
drwxr-xr-x.  2 mysql mysql    86 Aug 31 16:45 support-files

8:安装和初始化数据库
安装

   ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/2017-08-31T08:50:23.910440Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-31T08:50:23.910635Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/--datadir=/usr/local/mysql/data/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' con
figuration directive.2017-08-31T08:50:24.709286Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-08-31T08:50:24.767540Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-08-31T08:50:24.892629Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 6e083b8f-8e29-11e7-88b1-
005056b427be.2017-08-31T08:50:24.895674Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-08-31T08:50:24.896645Z 1 [Note] A temporary password is generated for root@localhost: gFamcspKm2+u

报错[ERROR] Can’t find error-message file ‘/usr/local/mysql/–datadir=/usr/local/mysql/data/share/errmsg.sys’. Check error-message file location and ‘lc-messages-dir’ con

解决

[root@dbserver bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --lc_messages_dir=/usr/local/mysql/share --lc_messages=en_US
2017-08-31T09:00:54.941514Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-08-31T09:00:56.364312Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-08-31T09:00:56.602211Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-08-31T09:00:56.668145Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: e69986d2-8e2a-11e7-a335-
005056b427be.2017-08-31T09:00:56.671464Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-08-31T09:00:56.672453Z 1 [Note] A temporary password is generated for root@localhost: qfuqvCsHb2!.

9配置my.cnf
接下来进入/usr/local/mysql/support-files/目录下
查看是否存在my-default.cnf文件,如果存在直接copy到/etc/my.cnf文件中

    [root@dbserver mysql]# cp -a ./support-files/my-default.cnf /etc/my.cnf

如果不存在my-default.cnf文件,则在/etc/目录下创建my.cnf,并写入以下内容

#[mysql]
#basedir=/usr/local/mysql/
#datadir=/usr/local/mysql/data/  

10启动服务

[root@dbserver mysql]# cd bin/
[root@dbserver bin]# ./mysqld_safe --user=mysql &
[2] 10436
[root@dbserver bin]# Logging to '/var/log/mysql/mysql.log'.
2017-08-31T09:52:15.806633Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2017-08-31T09:52:16.292949Z mysqld_safe mysqld from pid file /var/run/mysql/mysql.pid ended

11将mysqld服务加入开机自启动项。
将{mysql}/ support-files/mysql.server 拷贝为/etc/init.d/mysql并设置运行权限,这样就可以使用service mysql命令启动/停止服务,
否则就只能使用{mysql}/bin/mysqld_safe &命令来启动服务
还需要把mysql.server中basedir的相关路径,改为自定义的路径,默认路径是/usr/local/mysql

[root@dbserver support-files]# cp mysql.server /etc/init.d/mysql
[root@dbserver support-files]# chmod +x /etc/init.d/mysql
-- 把mysql注册为开机启动的服务
[root@dbserver support-files]# chkconfig --add mysql
-- 查看是否添加成功
[root@dbserver support-files]#  chkconfig --list mysql
Note: This output shows SysV services only and does not include nativesystemd services. SysV configuration data might be overridden by nativesystemd configuration.If you want to list systemd services use 'systemctl list-unit-files'.To see services enabled on particular target use'systemctl list-dependencies [target]'.mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off

12启动服务

[root@dbserver bin]# service mysql start
Starting MySQL.Logging to '/var/log/mysql/mysql.log'.ERROR! The server quit without updating PID file (/var/lib/mysql/dbserver.pid).

解决

[root@dbserver mysql]# rm  /etc/my.cnf
rm: remove regular file '/etc/my.cnf'? y
[root@dbserver mysql]# /etc/init.d/mysql start
Starting MySQL.Logging to '/usr/local/mysql/data/dbserver.err'.SUCCESS!
[root@dbserver mysql]# service mysql start
Starting MySQL SUCCESS!

13登录mysql

[root@dbserver bin]# ./mysql -u root -p
密码是第八步产生的密码

14设置密码

mysql>  set password=password("root");
Query OK, 0 rows affected, 1 warning (0.00 sec)
注意不要使用单引号,为什么?你自己试试就知道了

15设置远程登录权限

mysql>  grant all privileges on *.* to'root' @'%' identified by 'root';
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)mysql> quit
Bye

转载于:https://www.cnblogs.com/feiZhou/p/9344132.html

linux安装mysql5.7.19相关推荐

  1. centos安装mysql5.7.19_Linux下Centos7安装Mysql5.7.19的详细教程

    1.下载mysql 2.选择源码包,通用版点击下载 直接下载就可以了,不用登录 3.解压编译 tar -zxvf mysql-5.7.19.tar.gz cd mysql-5.7.19.tar.gz ...

  2. CentOS6.9 下编译安装MySQL5.7.19

    官网:https://www.mysql.com/ 下载地址:https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.19.tar.gz 一.准备工作 ...

  3. linux-ubuntu 安装mysql5.7.19的一些坑

    2019独角兽企业重金招聘Python工程师标准>>> linux-ubuntu 安装mysql5.7.19的一些坑 在linux下安装MySQL有很多介绍,流程大同小异,但往往一些 ...

  4. CentOS7安装mysql5.7.19的手顺,步骤(非常详细)

    CentOS7安装mysql5.7.19手顺 1.首先确认系统是否已经安装了mysql或者mariaDB rpm -qa | grep mysql rpm -qa | grep mariaDB 2.如 ...

  5. linux如何卸载mysql5.7,Linux下Mysql5.7.19卸载方法

    Linux下Mysql5.7.19卸载方法 1.查找以前是否装有mysql 命令:rpm -qa|grep -i mysql 可以看到mysql的两个包: mysql-*..*.RHEL** mysq ...

  6. mysql安装 linux 5.6,Linux安装MySql5.6版详细教程

    Linux安装MySql5.6版详细教程 Szx • 2019 年 02 月 26 日 首先下载mysql,然后上传到 /usr/local/tmp/下(如果没有这个目录创建一个即可或者存放其他目录) ...

  7. server2016安装mysql_windows server2016安装MySQL5.7.19解压缩版教程详解

    记录了MySQL 5.7.19 winx64解压缩版安装教程,具体内容如下 系统环境:Win7 x64 软件准备:mysql 5.7.19 winx64 配置安装流程 具体安装如下: 1.把 mysq ...

  8. linux mysql 5.6.24_Mysql实例Linux安装MySQL5.6.24使用文字说明

    <Mysql实例Linux安装MySQL5.6.24使用文字说明>要点: 本文介绍了Mysql实例Linux安装MySQL5.6.24使用文字说明,希望对您有用.如果有疑问,可以联系我们. ...

  9. Linux安装MYSQL5.7教程(一次成功)

    1.Linux安装mysql5.7.26 本次安装环境: mysql: mysql-5.7.26-linux-glibc2.12-x86_64linux: [root@192 ~]# cat /etc ...

最新文章

  1. etc下没有mysql_我在linux下,安装mysql的时候,cp support-files/my-medium.cnf /etc/my.cnf找不到my-medium.cnf...
  2. 辰星计划 2021 | 璀璨起航,旷视春季实习生招募开启
  3. oracle 动态sql列转行_SQL优化笔记分享:34条实用经验可别错过!
  4. unity 下一帧执行_理解Unity中的优化(三):协程(Coroutines)
  5. ansible自动化部署
  6. Docker基础入门总结
  7. 分布式链路跟踪中的traceid和spanid代表什么?
  8. oracle给表赋清空权限,oracle建表赋权限
  9. ASP.NET MVC2之Model Binder
  10. nuxtjs+express+vue2+vuex搭建的服务端渲染(SSR)个人网站项目
  11. 比较ole db/odbc/ado/ado.net/jdbc
  12. Java基准测试工具JMH使用
  13. MySQL — 数据库的基本概念、安装并配置MySQL、MySQL的基本使用、在项目中操作MySQL、前后端的身份认证
  14. 到底还有没有月薪3万以下的程序员?程序员工资真的这么高?
  15. Python挑战游戏( PythonChallenge)闯关之路Level- 6
  16. Adobe Photoshop CC 2017 (32 Bit) 软件安装
  17. 汤姆斯的天堂梦(par)
  18. 2022登高架设考试模拟100题模拟考试平台操作
  19. python爬猫眼电影影评,EX1 | 用Python爬取猫眼电影 APP 关于《无双》电影评论
  20. 巧用美女照做微信吸粉,你会做吗?

热门文章

  1. [Bugku CTF——Pwn] pwn2
  2. Mysql日期和时间函数大全
  3. 解决执行 df -h 卡住,yum和rpm都无法安装软件问题
  4. python pep8
  5. Mysql主从复制,实现数据同步
  6. SMTP Error: Could not connect to SMTP host
  7. 记录到日志中的异常栈缺失
  8. NGUI-Tweens
  9. sqlserver 分页存储过程
  10. Android Context.bindService 返回 false 问题