zoukankan      html  css  js  c++  java
  • linux非root用户安装5.7.27版本mysql

      先下安装包,到mysql官网https://dev.mysql.com/downloads/mysql/选好安装包版本、操作系统类型(默认是最新版本,点击右边链接Looking for previous GA versions?进行自选):

      下完安装包mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz后,通过rz上传至linux的wlf用户soft目录下,并解压:

    $ cd soft
    $ rz
    $ cd ..
    $ tar zxvf soft/mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz

      创建软连接:

    $ ln -s mysql-5.7.27-linux-glibc2.12-x86_64 mysql

      进入软连接目录:

    $ cd mysql

      通过vi新增mysql配置文件my.cnf,内容如下:

    [client]   
    port=3336  
    socket=/home/wlf/mysql/mysql.sock  
    
    [mysqld]
    port=3336
    basedir=/home/wlf/mysql
    datadir=/home/wlf/mysql/data
    pid-file=/home/wlf/mysql/mysql.pid
    socket=/home/wlf/mysql/mysql.sock
    log_error=/home/wlf/mysql/error.log
    server-id=100

      安装mysql:

    $ bin/mysqld --defaults-file=/home/wlf/mysql/my.cnf --initialize --user=wlf --basedir=/home/wlf/mysql --datadir=/home/wlf/mysql/data

      启动mysql:

    $ bin/mysqld_safe --defaults-file=/home/wlf/mysql/my.cnf  --user=wlf &
    [1] 1253
    $ 2019-09-20T04:16:20.253918Z mysqld_safe Logging to '/home/wlf/mysql/error.log'.
    2019-09-20T04:16:20.292670Z mysqld_safe Starting mysqld daemon with databases from /home/wlf/mysql/data

      克隆会话打开另一个窗口,进入wlf用户的mysql目录,获取密码:

    $ cat error.log | grep root@localhost
    2019-09-20T03:47:05.657319Z 1 [Note] A temporary password is generated for root@localhost: 6)j;ng7%-(SP

      登陆mysql:

    $ bin/mysql -u root -p
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

      不存在/tmp/mysql.sock,我们在my.cnf配置的mysql.sock路径是/home/wlf/mysql/mysql.sock,所以当mysql去找这个文件时,我们让它换个地方去找:

    ln -s /home/wlf/mysql/mysql.sock /tmp/mysql.sock

      再次登录,输入之前拿到的密码6)j;ng7%-(SP后登陆成功:

    $ bin/mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.27
    
    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> 

      我们修改下密码:

    mysql> set password for 'root'@'localhost' = password('123456');
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

      打完收工。如果不想用root用户,而是新建自己的用户,参见5.7.27版本mysql新增用户

  • 相关阅读:
    仿新浪首页、主题、详情页,纯html静态页面
    hdoj 4790 Just Random 【数学】
    Codeforces 97B Superset 平面分治
    HDU 1017 A Mathematical Curiosity【看懂题意+穷举法】
    Codeforces Round #221 (Div. 2) D
    一个bug在redmine中的诞生到终结
    hi3531 SDK已编译文件系统制作jffs2文件系统镜像并解决这个问题 .
    js前端3des加密 后台java解密
    进程经常使用小知识汇总
    泛型集合的使用
  • 原文地址:https://www.cnblogs.com/wuxun1997/p/11556403.html
Copyright © 2011-2022 走看看