centos6.9使用二进制包安装mysql5.7

[toc]

官方文档:

https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

安装步骤:

1、下载并解压下载的二进制包

tar -xvf MysqL-5.7.20-linux-glibc2.12-x86_64.tar
tar xvf MysqL-5.7.20-linux-glibc2.12-x86_64.tar.gz

2、移动解压包到/usr/local 下,并改名为MysqL5.7

[root@credithwsx MysqL]# mv MysqL-5.7.20-linux-glibc2.12-x86_64 /usr/local/MysqL5.7

3、安装依赖包(MysqL依赖于libaio 库 和numactl

yum install libaio
yum install numactl

4、要安装和使用MysqL二进制发行版,命令序列如下所示:

shell> groupadd MysqL
shell> useradd -r -g MysqL -s /bin/false MysqL shell> cd /usr/local shell> tar zxvf /path/to/MysqL-VERSION-OS.tar.gz
shell> ln -s full-path-to-MysqL-VERSION-OS MysqL
shell> cd MysqL shell> mkdir MysqL-files shell> chown MysqL:MysqL MysqL-files
shell> chmod 750 MysqL-files
shell> bin/MysqLd --initialize --user=MysqL shell> bin/MysqL_ssl_rsa_setup
shell> bin/MysqLd_safe --user=MysqL &
# Next command is optional
shell> cp support-files/MysqL.server /etc/init.d/MysqL.server

5、初始化数据库与密码

[root@credithwsx MysqL5.7]# bin/MysqLd --initialize --user=MysqL

2017-12-19T09:05:32.278790Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-12-19T09:05:32.279930Z 0 [ERROR] Can't find error-message file '/usr/local/MysqL/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2017-12-19T09:05:36.374681Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-12-19T09:05:37.028680Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-12-19T09:05:37.182429Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: c73d1bdd-e49b-11e7-be13-525400e66d7c.
2017-12-19T09:05:37.200319Z 0 [Warning] Gtid table is not ready to be used. Table 'MysqL.gtid_executed' cannot be opened.
2017-12-19T09:05:37.204842Z 1 [Note] A temporary password is generated for root@localhost: =cD1U#t

6、修改my.cnf 配置文件增加basedir和datadir

vim /etc/my.cnf

basedir=/usr/local/MysqL5.7/
datadir=/usr/local/MysqL5.7/data

7、添加链接,直接运行MysqL就可以打开 MySQL命令

[root@credithwsx MysqL5.7]# ln -s /var/lib/MysqL/MysqL.sock /tmp/

[root@credithwsx MysqL5.7]# ln -s $(pwd)/bin/MysqL /usr/bin

报错:ERROR 2002 (HY000): Can't connect to local MysqL server through socket '/tmp/MysqL.sock' (2)

[root@credithwsx MysqL5.7]# ps -aux |grep MysqL
Warning: bad Syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 1830 0.0 0.0 145024 1620 pts/3 S 15:29 0:00 su - MysqL
MysqL 1831 0.0 0.0 108324 1868 pts/3 S+ 15:29 0:00 -bash
root 1880 0.0 0.0 102104 4044 ? Ss 15:30 0:00 sshd: MysqL [priv]
MysqL 1885 0.0 0.0 102104 1896 ? S 15:30 0:00 sshd: MysqL@pts/5
MysqL 1886 0.0 0.0 108324 1896 pts/5 Ss 15:30 0:00 -bash
root 1987 0.0 0.0 145024 1616 pts/2 S 15:55 0:00 su - MysqL
MysqL 1988 0.0 0.0 108328 1872 pts/2 S 15:55 0:00 -bash
root 2751 0.0 0.0 106220 1580 pts/6 S 17:08 0:00 /bin/sh /usr/local/MysqL5.7//bin/MysqLd_safe --datadir=/var/lib/MysqL --pid-file=/var/lib/MysqL/credithwsx.pid
MysqL 2915 0.2 2.3 1243240 189952 pts/6 Sl 17:08 0:00 /usr/local/MysqL5.7/bin/MysqLd --basedir=/usr/local/MysqL5.7 --datadir=/var/lib/MysqL --plugin-dir=/usr/local/MysqL5.7/lib/plugin --user=MysqL --log-error=/var/log/MysqLd.log --pid-file=/var/lib/MysqL/credithwsx.pid --socket=/var/lib/MysqL/MysqL.sock
root 2952 0.0 0.0 103332 892 pts/6 S+ 17:11 0:00 grep MysqL

8、使用密码连接不了MysqL

解决方法: 在/etc/my.cnf 中添加 skip-grant-tables 跳过校验。(#号是注释)

centos6.9使用二进制包安装mysql5.7

进入MysqL修改root帐号的密码,在重新登录就好。

MysqL -u root -p
use MysqL

ALTER USER 'root'@'localhost' IDENTIFIED BY 'ICKLjPVmClvv1XtuCNoXXXXXXXXX';

如果上述操作不可行,视情况使用:
update user set authentication_string=PASSWORD('newpass') where User='root';

ALTER USER 'root'@'localhost' IDENTIFIED BY 'ICKLjPVmClvv1XtuCNoXXXXXXXX';

相关文章

优化MySQL数据库发布系统存储的方法有:1.mysql库主从读写分...
使用mysql的方法:在“我的电脑”→右键→“管理”→“服务”...
在mysql中查看root用户权限的方法:1.命令行启动mysql服务;...
MySQL主从复制是用来备份一个与主数据库一样环境的从数据库,...
运行mysql的方法1.启动mysql服务,在“我的电脑”→右键→“...
开启mysql的方法1.可以通过快捷键win+r,输入cmd,打开窗口,...