【MySQL日常运维】Linux安装MySQL5.7.32

news/2024/11/29 7:40:30/

【MySQL日常运维】Linux安装MySQL5732

# 添加mysql用户
[root@centos76mysql57 /]#  useradd mysql
[root@centos76mysql57 opt]# ls -lth
total 631M
-rw-r--r--. 1 root root 631M Sep  4 13:44 mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
# 解压文件
[root@centos76mysql57 opt]# tar -zxvf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
[root@centos76mysql57 opt]# mv mysql-5.7.32-linux-glibc2.12-x86_64 /usr/local/mysql
[root@centos76mysql57 opt]# cd /usr/local/
[root@centos76mysql57 local]# ls
bin  etc  games  include  lib  lib64  libexec  mysql  sbin  share  src
[root@centos76mysql57 local]# ls -lth
total 0
drwxr-xr-x. 9 root root 129 Oct  2 16:12 mysql
drwxr-xr-x. 5 root root  49 Dec  4  2018 share
drwxr-xr-x. 2 root root   6 Apr 11  2018 bin
drwxr-xr-x. 2 root root   6 Apr 11  2018 etc
drwxr-xr-x. 2 root root   6 Apr 11  2018 games
drwxr-xr-x. 2 root root   6 Apr 11  2018 include
drwxr-xr-x. 2 root root   6 Apr 11  2018 lib
drwxr-xr-x. 2 root root   6 Apr 11  2018 lib64
drwxr-xr-x. 2 root root   6 Apr 11  2018 libexec
drwxr-xr-x. 2 root root   6 Apr 11  2018 sbin
drwxr-xr-x. 2 root root   6 Apr 11  2018 src
# 创建数据目录并赋予权限
[root@centos76mysql57 local]# mkdir -p  /data/mysql
[root@centos76mysql57 local]# 
[root@centos76mysql57 local]# chown mysql:mysql -R /data/mysql
# 配置环境变量
[root@centos76mysql57 support-files]# vi /etc/profile export 
PATH=/usr/local/mysql/bin:$PATH
[root@centos76mysql57 support-files]# source /etc/profile
# 配置my.cnf 
[root@centos76mysql57 mysql]# vi /etc/my.cnf 
[root@centos76mysql57 mysql]# more /etc/my.cnf 
[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true# 初始化数据库
[root@centos76mysql57 mysql]# cd /usr/local/mysql/
[root@centos76mysql57 bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize
./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
[root@centos76mysql57 bin]# yum -y install numactl
[root@centos76mysql57 bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize
[root@centos76mysql57 bin]# cd /data/mysql/
[root@centos76mysql57 mysql]# ls
auto.cnf    client-cert.pem  ib_logfile0  mysql               private_key.pem  server-key.pem
ca-key.pem  client-key.pem   ib_logfile1  mysql.err           public_key.pem   sys
ca.pem      ib_buffer_pool   ibdata1      performance_schema  server-cert.pem
[root@centos76mysql57 mysql]# ls -lth
total 109M
-rw-r-----. 1 mysql mysql  12M Oct  2 16:24 ibdata1
-rw-r-----. 1 mysql mysql  48M Oct  2 16:24 ib_logfile0
-rw-r-----. 1 mysql mysql  431 Oct  2 16:24 ib_buffer_pool
drwxr-x---. 2 mysql mysql 8.0K Oct  2 16:24 sys
drwxr-x---. 2 mysql mysql 4.0K Oct  2 16:24 mysql
drwxr-x---. 2 mysql mysql 8.0K Oct  2 16:24 performance_schema
-rw-r-----. 1 mysql mysql  690 Oct  2 16:24 mysql.err
-rw-------. 1 mysql mysql 1.7K Oct  2 16:24 private_key.pem
-rw-r--r--. 1 mysql mysql  452 Oct  2 16:24 public_key.pem
-rw-r--r--. 1 mysql mysql 1.1K Oct  2 16:24 client-cert.pem
-rw-------. 1 mysql mysql 1.7K Oct  2 16:24 client-key.pem
-rw-r--r--. 1 mysql mysql 1.1K Oct  2 16:24 server-cert.pem
-rw-------. 1 mysql mysql 1.7K Oct  2 16:24 server-key.pem
-rw-r--r--. 1 mysql mysql 1.1K Oct  2 16:24 ca.pem
-rw-------. 1 mysql mysql 1.7K Oct  2 16:24 ca-key.pem
-rw-r-----. 1 mysql mysql   56 Oct  2 16:24 auto.cnf
-rw-r-----. 1 mysql mysql  48M Oct  2 16:24 ib_logfile1# 查看密码
[root@centos76mysql57 mysql]# cat /data/mysql/mysql.err
2022-10-02T16:24:51.682299Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-10-02T16:24:51.708503Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-10-02T16:24:51.763628Z 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: bdde105f-426e-11ed-8906-0242ac110003.
2022-10-02T16:24:51.764563Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-10-02T16:24:52.159541Z 0 [Warning] CA certificate ca.pem is self signed.
2022-10-02T16:24:52.389241Z 1 [Note] A temporary password is generated for root@localhost: xor9k*ntt/,P# 启动数据库
[root@centos76mysql57 support-files]# pwd
/usr/local/mysql/support-files
[root@centos76mysql57 mysql]# systemctl enable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on
[root@centos76mysql57 support-files]# ./mysql.server start
Starting MySQL. SUCCESS! 
[root@centos76mysql57 support-files]# ./mysql.server stop 
Shutting down MySQL.. SUCCESS! 
[root@centos76mysql57 support-files]#  cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@centos76mysql57 support-files]#  systemctl start mysqld
[root@centos76mysql57 support-files]# systemctl status mysqld
● mysqld.service - LSB: start and stop MySQLLoaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)Active: active (running) since Sun 2022-10-02 16:30:27 UTC; 4s agoDocs: man:systemd-sysv-generator(8)Process: 3989 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS)CGroup: /system.slice/docker-6e3bac4fe05fec8287b9e660741026793319bc23b2ad879f067a9778a89ea7a6.scope/system.slice/mysqld.service├─4002 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/mysql.pid└─4229 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/...Oct 02 16:30:26 centos76mysql57 systemd[1]: Starting LSB: start and stop MySQL...
Oct 02 16:30:27 centos76mysql57 mysqld[3989]: Starting MySQL. SUCCESS!
Oct 02 16:30:27 centos76mysql57 systemd[1]: Started LSB: start and stop MySQL.# 修改密码
[root@centos76mysql57 support-files]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.32Copyright (c) 2000, 2020, 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> ALTER USER 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

http://www.ppmy.cn/news/334871.html

相关文章

心酸,上班带薪拉屎被老板骂了……

👇👇关注后回复 “进群” ,拉你进程序员交流群👇👇 作者丨了不起的你我他 来源丨了不起的程序员(ID:great_developer) 珍爱PP 人人有责 写在最后 了不起的程序员摸鱼基地成立了&…

Linux安装MySQL5.7(敲硬核、敲简单der)

文章目录 1.安装前准备2.修改配置文件3.创建操作数据库的用户4.启动数据库5.设置远程访问 1.安装前准备 检查系统有没有安装mysql,需要卸载 rpm -qa | grep mysql如果你的系统有Mariadb数据库,需要卸载 rpm -qa | grep mariadb # 如果存在&#xff0c…

如果员工是老油条,那他的老板也是

分享嘉宾:袁征(Eric Yuan),视频会议软件提供商zoom创始人兼首席执行官。在创立zoom之前,曾在WebEx工作,将部门的工程师从区区10名发展到了超过800名,并将收入增长从0发展到超过8亿美元。2018被知…

一个优秀员工的离职成本有多恐怖!老板看过来!

一个员工的离职成本,很恐怖! 对许多企业主和大老板来说,招聘这个事情历久弥新,每个老板都想招到一个得力又优秀的员工。有新人入职,也就有老人离职。招聘新人为企业注入活力固然重要,但是“老人”也需固守。…

2019年“最惨”的老板:公司倒了,员工跑了,自己也被抓了

点击上方 "码农真经" 关注,星标或者置顶 22点24分准时推送,第一时间送达 来源:数码妖精 | 编辑:真经君 链接:t.cn/AisbnH5q 码农真经(ID:coder_experience)第 73 次推文 图片来自网络 上一篇:告…

我和我的怨种老板

嗨,大家好,今天来吐槽一下我的公司跟我的老板。 鄙人是一个心情开朗,比较看得开的人,一般不仅仅计较,心也比较大,做事总能大事化小小事化了,但请看我说的是一般,如果遇到不一般的呢…

[转贴] 一封让老板看后一夜没睡的辞职信

这是我两年前写的。老板看过之后告诉我:一夜没睡,刺激很大! 两年间,我跳槽九次,从作WAP开发到作网管,最短11天,最长是这次。那时我找不准究竟要干什么,跳槽是我获取新知识的手段&…

感动打工人好老板,俞敏洪给自己2022打8分:没有欠员工一分钱工资

近日,新东方创始人俞敏洪在跨年直播中称,如果要给2022年打分,会给自己打8分。因为这一年,他做了几件事情。 第一件事情就是稳定了新东方的发展,不管2022年新东方怎么变化,新东方还有5万多个员工&#xff0c…