笔记/centos系统离线安装MySQL

MySQL包百度网盘链接

链接:https://pan.baidu.com/s/11sQHYTRe0MeYVAiIz3pBoQ 
提取码:1qaz

上传安装包到/usr/local

[root@bogon ~]# cd /usr/local

[root@bogon local]# ls

bin  etc  games  include  lib  lib64  libexec  mysql-8.0.31-linux-glibc2.12-x86_64.tar.xz  sbin  share  src

解压安装包

[root@bogon local]#xz -d mysql-8.0.31-linux-glibc2.12-x86_64.tar.x

[root@bogon local]# ls

bin  etc  games  include  lib  lib64  libexec  mysql-8.0.31-linux-glibc2.12-x86_64.tar  sbin  share  src

[root@bogon local]# tar -xvf mysql-8.0.31-linux-glibc2.12-x86_64.tar

[root@bogon local]# ls

bin  etc  games  include  lib  lib64  libexec  mysql-8.0.31-linux-glibc2.12-x86_64  mysql-8.0.31-linux-glibc2.12-x86_64.tar  sbin  share  src

[root@bogon local]# mv mysql-8.0.31-linux-glibc2.12-x86_64 mysql

[root@bogon local]# ls

bin  etc  games  include  lib  lib64  libexec  mysql  mysql-8.0.31-linux-glibc2.12-x86_64.tar  sbin  share  src

配置(红色字体添加黄色字体注释掉)

[root@bogon local]# vi /etc/my.cnf

[client]

port=3306

socket=/var/lib/mysql/mysql.sock

 

[mysqld]

port=3306

user=mysql

socket=/var/lib/mysql/mysql.sock

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data      

 

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# Settings user and group are ignored when systemd is used.

# If you need to run mysqld under a different user or group,

# customize your systemd unit file for mariadb according to the

# instructions in http://fedoraproject.org/wiki/Systemd

 

#[mysqld_safe]

#log-error=/var/log/mariadb/mariadb.log

#pid-file=/var/run/mariadb/mariadb.pid

 

#

# include all files from the config directory

#

!includedir /etc/my.cnf.d

[root@bogon local]# groupadd mysql

[root@bogon local]# useradd -g mysql mysql

[root@bogon local]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

2022-11-08T09:12:16.598455Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.

2022-11-08T09:12:16.598869Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.31) initializing of server in progress as process 7691

2022-11-08T09:12:16.606091Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.

2022-11-08T09:12:17.959146Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.

2022-11-08T09:12:19.315060Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: CvMr4>ugo9#(随机密码后面要用)

[root@bogon local]# mkdir -p /var/lib/mysql ; chown -R mysql:mysql /var/lib/mysql

[root@bogon local]# ln -s /usr/local/mysql/bin/mysql /usr/bin

[root@bogon local]# /usr/local/mysql/support-files/mysql.server start

Starting MySQL.Logging to '/usr/local/mysql/data/bogon.err'.

. SUCCESS!

[root@bogon local]# mysql -u root -p

Enter password:这里输入前面紫色字体的随机密码

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 12

Server version: 8.0.31

 

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

 

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 '1.q';

Query OK, 0 rows affected (0.00 sec)

 

mysql> exit

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(mysql,centos,数据库,运维,linux)