centos6.9使用二进制包安装mysql5.7
admin
2023-05-09 20:21:48
0

[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';

相关内容

热门资讯

燃气热水器需要多少升的 一般在选择燃气热水器的时候,按照家庭内部的使用水的人数来决定,一般如果四个人的话,可以选择40到60...
32升燃气热水器安装方法 燃气热水器是现代家庭生活中非常重要的设备,它不仅方便了我们的生活,提高了生活品质,同时也需要我们重视...
燃气热水器12升和13升的区别... 燃气热水器12升和13升的区别大吗:区别不大。12升就是热水器的额定加热能力是每分钟可以提升水温25...
燃气热水器温度升不上去的原因是... 1、燃气的压力不够大,导致水温无法升高。2、热水器内部的电池电量已经不够运转热水器。3、没有做好卫生...
海尔滚筒洗衣机衣服放进后门锁不... 卡锁松懈或老化故障可以找专业的售后将卡锁部分卸下换一个新的就可以正常使用。可以适当的拿出些许衣服以释...
小米、特斯拉、比亚迪相继调价 ...   小米、特斯拉、比亚迪相继调价  【小米、特斯拉、比亚迪相继调价】2026年5月,中国新能源车市上...
雨雨雨雨雨雨!14日至19日河... 晴雨转换!今天起河南雨雨雨雨雨雨本周河南天气呈现先晴后雨的特点,在经历了前半段晴热模式之后,今天我省...
进出口总量全省第6、鲜苹果出口... 2026年一季度,三门峡市外贸经济稳健向好,交出一份亮眼成绩单:全市实现进出口总值57.9亿元,同比...
法国外交部回应特朗普访华 据凤凰卫视报道,美国总统特朗普访问中国,中美关系走向引发欧洲关注。法国外交部发言人5月13日在巴黎接...
特朗普社媒实际发帖人现身:34... 现年34岁的行政助理娜塔莉·哈普是美国总统特朗普的“资深心腹”,目前已成为协助特朗普在社交平台“真实...