Mysql 5.7.21 install for Linux

Mysql 5.7.21 install for Linux


一:下载
二:安装前准备
三:安装

一:下载
1 下载地址
dev.mysql.com/downloads/mysql
2 安装包
mysql-5.7.21-linux-glibc2.12-x86_64.tar


二:安装前准备
1 卸载系统默认安装的mysql(谨慎操作)
[root@rac1 bin]# rpm -qa|grep mysql
[root@rac1 bin]# rpm -e mysql-connector-odbc-5.1.5r1144-7.el6.x86_64 --nodeps
[root@rac1 bin]# rpm -e mysql-devel-5.1.66-2.el6_3.x86_64 --nodeps
[root@rac1 bin]# rpm -e mysql-5.1.66-2.el6_3.x86_64 --nodeps
[root@rac1 bin]# rpm -e mysql-libs-5.1.66-2.el6_3.x86_64 --nodeps
[root@rac1 bin]# rpm -e mysql-server-5.1.66-2.el6_3.x86_64 --nodeps
......

2 创建mysql用户和组
[root@rac1 bin]# groupadd mysql
[root@rac1 bin]# useradd -g mysql mysql
[root@rac1 bin]# id mysql
uid=493(mysql) gid=5006(mysql) groups=5006(mysql)
[root@rac1 bin]# passwd mysql

三:安装
1 解压
[root@rac1 mysql]# cd /package/mysql/
[root@rac1 mysql]# ll -rth
total 641M
-rw-r--r-- 1 root root 641M Jun  4 10:22 mysql-5.7.21-linux-glibc2.12-x86_64.tar

[root@rac1 mysql]# tar -xvf mysql-5.7.21-linux-glibc2.12-x86_64.tar 
mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
mysql-test-5.7.21-linux-glibc2.12-x86_64.tar.gz

[root@rac1 mysql]# ll -rth
total 1.3G
-rw-r--r-- 1 7161 31415  28M Dec 28 12:18 mysql-test-5.7.21-linux-glibc2.12-x86_64.tar.gz
-rw-r--r-- 1 7161 31415 613M Dec 28 12:20 mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
-rw-r--r-- 1 root root  641M Jun  4 10:22 mysql-5.7.21-linux-glibc2.12-x86_64.tar

[root@rac1 mysql]# tar -zxvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

[root@rac1 mysql]# du -sh mysql-5.7.21-linux-glibc2.12-x86_64 
2.5G mysql-5.7.21-linux-glibc2.12-x86_64

[root@rac1 mysql]# cp -r mysql-5.7.21-linux-glibc2.12-x86_64 /usr/local/mysql
[root@rac2 etc]# chown mysql.mysql /usr/local/mysql -R

2 创建my.cnf
[root@rac1 ~]# cd /etc/
[root@rac1 etc]# touch my.cnf
[root@rac1 etc]# vi my.cnf
[mysqld]
datadir=/usr/local/mysql/data
log-error=/usr/local/mysql/data/error.log
pid-file=/usr/local/mysql/data/mysql.pid
socket=/usr/local/mysql/mysql.sock
user=mysql
tmpdir=/tmp

3 配置mysqld命令
[root@rac1 etc]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@rac1 etc]# chmod 755 /etc/init.d/mysqld
[root@rac1 etc]# vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data/mysql

4 开始安装
[mysql@rac1 mysql]$ pwd
/usr/local/mysql
[mysql@rac1 mysql]$ ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysql.pid --tmpdir=/tmp

[mysql@rac1 data]$ service mysqld status
MySQL is not running                                       [FAILED]

[mysql@rac1 data]$ service mysqld start
Starting MySQL..                                           [  OK  ]

5 mysql.sock
[mysql@rac1 bin]$ ./mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

[mysql@rac1 bin]$ ln -s /usr/local/mysql/mysql.sock /tmp/mysql.sock

6 登录mysql并修改密码
[mysql@rac1 data]$ pwd
/usr/local/mysql/data
[mysql@rac1 data]$ vi error.log 
2018-06-04T03:51:14.789564Z 1 [Note] A temporary password is generated for root@localhost: k7deH1nLvo_N

[mysql@rac1 bin]$ ./mysql -uroot -p'k7deH1nLvo_N'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.21

Copyright (c) 2000, 2018, 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> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> alter user 'root'@'localhost' identified by '123';
Query OK, 0 rows affected (0.10 sec)

[mysql@rac1 bin]$ ./mysql -uroot -p123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.19 sec)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29785807/viewspace-2155537/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29785807/viewspace-2155537/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值