热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Linuxmysql5.5.27_linux非root用户安装5.7.27版本mysql

先下安装包,到mysql官网https:dev.mysql.comdownloadsmysql选好安装包版本、操作系统类型(默认是最新版本,点击右边链接

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

03ae9b4cbaf944c1885adf59b967cd46.png

下完安装包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

获取密码:

$ 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,我们只有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用户,而是新建自己的用户,参见

标签:27,5.7,sock,mysqld,mysql,home,root,wlf

来源: https://www.cnblogs.com/wuxun1997/p/11556403.html



推荐阅读
author-avatar
eq2wq32wq
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有