概述
先下安装包,到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=3336socket=/home/wlf/mysql/mysql.sock
[mysqld]
port=3336basedir=/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@localhost2019-09-20T03:47:05.657319Z 1 [Note] A temporary password is generated for root@localhost: 6)j;ng7%-(SP
登陆mysql:
$ bin/mysql -u root -pERROR 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:
Welcometo the MySQL monitor. Commands end with ; or g.
Your MySQL connection idis 2Server version:5.7.27Copyright (c)2000, 2019, Oracle and/orits affiliates. All rights reserved.
Oracleis a registered trademark of Oracle Corporation and/orits
affiliates. Other names may be trademarksoftheir 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.00sec)
mysql>flush privileges;
Query OK,0 rows affected (0.00 sec)
打完收工。如果不想用root用户,而是新建自己的用户,参见5.7.27版本mysql新增用户。
来源:oschina
链接:https://my.oschina.net/u/4418711/blog/4258493
最后
以上就是拼搏蜜粉为你收集整理的mysql5.7 非root安装_linux非root用户安装5.7.27版本mysql的全部内容,希望文章能够帮你解决mysql5.7 非root安装_linux非root用户安装5.7.27版本mysql所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复