二进制包安装MySQL_5.7步骤安装包处理[root@adailinux src]# wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.1
二进制包安装MySQL_5.7
步骤
安装包处理
[root@adailinux src]# wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz[root@adailinux src]# tar zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
初始化
[root@adailinux src]# mv mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql[root@adailinux src]# cd /usr/local/mysql[root@adailinux mysql]# ./bin/mysqld --initialize --user=mysql --datadir=/data/mysql
错误排查
[root@adailinux mysql]# ./bin/mysqld --initialize --user=mysql --datadir=/data/mysql./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory解决办法:[root@adailinux mysql]# yum install -y libaio*
初始化
[root@adailinux mysql]# ./bin/mysqld --initialize --user=mysql --datadir=/data/mysql[Note] A temporary password is generated for root@localhost: 3A)2DdJLkcFP#注意:此时在此生成一个root密码!检测:[root@adailinux mysql]# echo $?0执行以下命令:[root@adailinux mysql]# ./bin/mysql_ssl_rsa_setup --datadir=/data/mysql
初始化完成!
配置MySQL
编辑MySQL配置文件:[root@adailinux mysql]# vim /etc/my.cnf[mysqld]basedir=/usr/local/mysqlport=3306datadir=/data/mysqlsocket=/tmp/mysql.sock将MySQL添加到系统服务:[root@adailinux mysql]# cp support-files/mysql.server /etc/init.d/mysqld[root@adailinux mysql]# vim /etc/init.d/mysqldbasedir=/usr/local/mysqldatadir=/data/mysql
- 启动服务
[root@adailinux mysql]# /etc/init.d/mysqld startStarting MySQL.Logging to '/data/mysql/adailinux.err'........ SUCCESS!
设置root密码
使用初始化密码登录,进入后直接设置密码,一定要设置一下新密码:[root@adailinux mysql]# /usr/local/mysql/bin/mysql -uroot -p'3A)¥#LkcFP'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 3Server version: 5.7.17Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.mysql> set password = password('12#¥%6');Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> quitBye
退出来,再使用新的密码登录就可以了!
设置密码:情景2
还有一种情况,就是不知道初始化密码vi /etc/my.cnf在[mysqld]下面增加一行skip-grant-tables重启 /etc/init.d/mysqld restart/usr/local/mysql/bin/mysql -uroot mysql> update user set authentication_string=password('123333') where user='root';退出来后,更改my.cnf,去掉刚加的 skip-grant-tables重启 /etc/init.d/mysqld restart此时就可以使用新的密码了。