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
获取密码:
$ 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