--
:
--
:
--
hugo-teek is loading...
通用二进制格式安装mysql-5-6-47
最后更新于:
1、实战:通用二进制格式安装 MySQL(mysql-5.6.47)-2024.4.6(测试成功)

目录
[toc]
实验环境
链接:https://pan.baidu.com/s/1Fl4duisOKh3QdjDC81V9jA?pwd=17ev
提取码:17ev
2024.4.6-实战:通用二进制格式安装 MySQL(mysql-5.6.47)-2024.4.6(测试成功)

1、下载url
https://downloads.mysql.com/archives/get/p/23/file/mysql-5.6.47-linux-glibc2.12-x86_64.tar.gz

2、准备用户
1[root@linux-test ~]#groupadd -r -g 306 mysql
2[root@linux-test ~]#useradd -r -g 306 -u 306 -d /data/mysql mysql
3、准备数据目录,建议使用逻辑卷
1#可选做,后面的脚本mysql_install_db可自动生成此目录(推荐还是这里做了为好)
2
3[root@linux-test ~]#mkdir -p /data/mysql
4[root@linux-test ~]#chown mysql:mysql /data/mysql
4、准备二进制程序
1[root@linux-test ~]#tar xvf mysql-5.6.47-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
2[root@linux-test ~]#cd /usr/local
3[root@linux-test local]#ln -s mysql-5.6.47-linux-glibc2.12-x86_64/ mysql
4[root@linux-test local]#chown -R root:root /usr/local/mysql/
5、准备配置文件
1[root@linux-test ~]#cd /usr/local/mysql
2[root@linux-test mysql]#vim /etc/my.cnf
3[mysqld]
4datadir = /data/mysql
5#保存退出,其他不行代表保持默认
⚠️ 注意:这里的方法和版本有关系
1cd /usr/local/mysql
2cp -b support-files/my-large.cnf /etc/my.cnf
3
4其它:
5vim /etc/my.cnf
6#mysql语句块中添加以下三个选项
7[mysqld]
8datadir = /data/mysql
9innodb_file_per_table = on #在mariadb5.5以上版的是默认值,可不加
10skip_name_resolve = on #禁止主机名解析,建议使用
6、创建数据库文件
1[root@linux-test ~]#cd /usr/local/mysql/
2[root@linux-test mysql]#./scripts/mysql_install_db --datadir=/data/mysql --user=mysql
3[root@linux-test mysql]#ls -l /data/mysql/
4total 110600
5-rw-rw---- 1 mysql mysql 12582912 Apr 1 07:21 ibdata1
6-rw-rw---- 1 mysql mysql 50331648 Apr 1 07:21 ib_logfile0
7-rw-rw---- 1 mysql mysql 50331648 Apr 1 07:21 ib_logfile1
8drwx------ 2 mysql mysql 4096 Apr 1 07:21 mysql
9drwx------ 2 mysql mysql 4096 Apr 1 07:21 performance_schema
10drwx------ 2 mysql mysql 6 Apr 1 07:21 test
11[root@linux-test mysql]#
7、准备服务脚本,并启动服务
1[root@linux-test mysql]#cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
2[root@linux-test mysql]#chkconfig --add mysqld
3[root@linux-test mysql]#service mysqld start
4Starting MySQL.Logging to '/data/mysql/linux-test.err'.
5 SUCCESS!
6[root@linux-test mysql]#
7
8
9#检查
10[root@linux-test ~]#service mysqld status
11 SUCCESS! MySQL running (6831)
12[root@linux-test ~]#chkconfig --list
13
14Note: This output shows SysV services only and does not include native
15 systemd services. SysV configuration data might be overridden by native
16 systemd configuration.
17
18 If you want to list systemd services use 'systemctl list-unit-files'.
19 To see services enabled on particular target use
20 'systemctl list-dependencies [target]'.
21
22mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
23netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
24network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
25[root@linux-test ~]#
6版本:
1cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
2chkconfig --add mysqld
3service mysqld start
7版本:
1#如果有对应的service 文件可以执行下面
2cp support-files/systemd/mariadb.service /usr/lib/systemd/system/
3systemctl daemon-reload
4systemctl enable --now mariadb
8、PATH路径
1[root@linux-test mysql]#echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
2[root@linux-test mysql]#. /etc/profile.d/mysql.sh
3
4##测试:
5[root@linux-test ~]#mysql
6Welcome to the MySQL monitor. Commands end with ; or \g.
7Your MySQL connection id is 1
8Server version: 5.6.47 MySQL Community Server (GPL)
9
10Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
11
12Oracle is a registered trademark of Oracle Corporation and/or its
13affiliates. Other names may be trademarks of their respective
14owners.
15
16Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
17
18mysql>
9、安全初始化
1#/usr/local/mysql/bin/mysql_secure_installation
2
3Enter current password for root (enter for none): #默认没密码,这里直接回车
4
5
6You already have your root account protected, so you can safely answer 'n'.
7Switch to unix_socket authentication [Y/n] #输入n(远程可以登录)
8
9#mysql.sock 使用unix socket登录(只能在本地登录,不能远程登录);
10/var/lib/mysql/mysql.sock文件
11
12Change the root password? [Y/n] #输入y
13New password: #输入密码:xyy520
14Re-enter new password:
15
16Remove anonymous users? [Y/n] #输入y
17
18Disallow root login remotely? [Y/n] #输入y,禁用root远程登录
19
20Remove test database and access to it? [Y/n] #输入y
21
22Reload privilege tables now? [Y/n] #输入y(是否加载权限)
10、测试
1[root@linux-test ~]#netstat -antlp|grep 3306
2tcp6 0 0 :::3306 :::* LISTEN 18288/mysqld
3[root@linux-test ~]#
4
5[root@linux-test ~]#mysql
6ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
7[root@linux-test ~]#mysql -uroot -pxyy520
8Warning: Using a password on the command line interface can be insecure.
9Welcome to the MySQL monitor. Commands end with ; or \g.
10Your MySQL connection id is 14
11Server version: 5.6.47 MySQL Community Server (GPL)
12
13Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
14
15Oracle is a registered trademark of Oracle Corporation and/or its
16affiliates. Other names may be trademarks of their respective
17owners.
18
19Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
20
21mysql> \s
22--------------
23mysql Ver 14.14 Distrib 5.6.47, for linux-glibc2.12 (x86_64) using EditLine wrapper
24
25Connection id: 14
26Current database:
27Current user: root@localhost
28SSL: Not in use
29Current pager: stdout
30Using outfile: ''
31Using delimiter: ;
32Server version: 5.6.47 MySQL Community Server (GPL)
33Protocol version: 10
34Connection: Localhost via UNIX socket
35Server characterset: latin1
36Db characterset: latin1
37Client characterset: utf8
38Conn. characterset: utf8
39UNIX socket: /tmp/mysql.sock
40Uptime: 8 min 2 sec
41
42Threads: 1 Questions: 48 Slow queries: 0 Opens: 68 Flush tables: 1 Open tables: 61 Queries per second avg: 0.099
43--------------
44
45mysql> select user,host,password from mysql.user;
46+------+-----------+-------------------------------------------+
47| user | host | password |
48+------+-----------+-------------------------------------------+
49| root | localhost | *ABE374A5F247C93961AD4726B39A5A84FA3BC3B1 |
50| root | 127.0.0.1 | *ABE374A5F247C93961AD4726B39A5A84FA3BC3B1 |
51| root | ::1 | *ABE374A5F247C93961AD4726B39A5A84FA3BC3B1 |
52+------+-----------+-------------------------------------------+
533 rows in set (0.00 sec)
54
55mysql>
shell一键安装
https://onedayxyy.cn/docs/mysql-install-bindary-shell 《实战:一键安装mysql-5.6二进制包脚本(mysql-5.6.42)(测试成功)》
此脚本测试成功,可直接一键安装

关于我
我的博客主旨:
- 排版美观,语言精炼;
- 文档即手册,步骤明细,拒绝埋坑,提供源码;
- 本人实战文档都是亲测成功的,各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人帮您解决问题,让我们一起进步!
🍀 微信二维码
x2675263825 (舍得), qq:2675263825。

🍀 微信公众号
《云原生架构师实战》

🍀 个人博客站点


🍀 语雀
https://www.yuque.com/xyy-onlyone

🍀 csdn
https://blog.csdn.net/weixin_39246554?spm=1010.2135.3001.5421

🍀 知乎
https://www.zhihu.com/people/foryouone

最后
好了,关于本次就到这里了,感谢大家阅读,最后祝大家生活快乐,每天都过的有意义哦,我们下期见!
📡
👤
作者:
余温Gueen
🌐
版权:
本站文章除特别声明外,均采用
CC BY-NC-SA 4.0
协议,转载请注明来自
余温Gueen Blog!
推荐使用微信支付

推荐使用支付宝
