Centos7环境使用Mysql离线安装包安装Mysql5.7

服务器环境:centos7 x64

需要安装:mysql5.7+

1)检查mysql组合用户是否存在

2)若不存在,则创建mysql组和用户

对于版本选择,您可以选择以下两种方式:

[En]

For version selection, you can choose the following two ways:

1)使用Red Hat Enterprise Linux

2)使用Linux – Generic

2)百度网盘

注意:上边三种方式找mysql离线安装包的方式都可以。

设置文件及目录权限:

1)获得mysql初始密码

2)修改密码

3)验证新密码是否登录成功:

[root@localhost ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
[root@localhost ~]# rm /etc/my.cnf
rm: cannot remove ‘/etc/my.cnf’: No such file or directory
[root@localhost ~]# rpm -qa | grep mysql
[root@localhost ~]# cat /etc/group | grep mysql
[root@localhost ~]# cat /etc/passwd | grep mysql
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -g mysql mysql
[root@localhost ~]# passwd mysql
Changing password for user mysql.

New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
Sorry, passwords do not match.

New password:
Retype new password:
passwd: all authentication tokens updated successfully.

[root@localhost ~]# cd /home/
[root@localhost home]# ll
total 4
drwxr-xr-x.  3 root     root       18 Apr 28 20:35 install
drwx------.  3 mysql    mysql      78 Aug  7 07:02 mysql
drwx------. 15 panhusun panhusun 4096 Aug  7 06:52 panhusun
drwxr-xr-x.  2 root     root        6 Apr 21 01:12 server
drwxr-xr-x.  4 root     root      214 May 11 02:43 tar
[root@localhost home]# cd tar/
[root@localhost tar]# ll
total 559012
-rwxr-xr-x.  1 root root      11156 Apr 20 03:54 get_helm.sh
-rw-r--r--.  1 root root   62468096 Apr 20 23:55 k3s
-rw-r--r--.  1 root root  503815168 Apr 20 04:28 k3s-airgap-images-amd64.tar
-rw-r--r--.  1 root root      15152 Oct  8  2021 k3s-selinux-0.4-1.el7.noarch.rpm
drwxr-xr-x. 11 root root       4096 May 11 02:49 libressl-3.5.2
-rw-r--r--.  1 root root    4039407 May 11 02:43 libressl-3.5.2.tar.gz
drwxr-xr-x. 14  501 games      4096 May 11 01:29 zlib-1.2.12
-rw-r--r--.  1 root root    2060528 May 11 01:58 zlib-1.2.12Upgrade.tar.gz
[root@localhost tar]# pwd
/home/tar
[root@localhost tar]# ^C
[root@localhost tar]# ll
total 1209952
-rwxr-xr-x.  1 root root      11156 Apr 20 03:54 get_helm.sh
-rw-r--r--.  1 root root   62468096 Apr 20 23:55 k3s
-rw-r--r--.  1 root root  503815168 Apr 20 04:28 k3s-airgap-images-amd64.tar
-rw-r--r--.  1 root root      15152 Oct  8  2021 k3s-selinux-0.4-1.el7.noarch.rpm
drwxr-xr-x. 11 root root       4096 May 11 02:49 libressl-3.5.2
-rw-r--r--.  1 root root    4039407 May 11 02:43 libressl-3.5.2.tar.gz
-rw-r--r--.  1 root root  666559924 Aug  7 07:04 mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
drwxr-xr-x. 14  501 games      4096 May 11 01:29 zlib-1.2.12
-rw-r--r--.  1 root root    2060528 May 11 01:58 zlib-1.2.12Upgrade.tar.gz
[root@localhost tar]# cp mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz /usr/local/
[root@localhost tar]# cd /usr/local/
[root@localhost local]# ll
total 650940
drwxr-xr-x. 2 root root       122 Apr 21 00:03 bin
drwxr-xr-x. 2 root root         6 Apr 10  2018 etc
drwxr-xr-x. 2 root root         6 Apr 10  2018 games
drwxr-xr-x. 2 root root        35 May 11 02:00 include
drwxr-xr-x. 2 root root         6 Apr 10  2018 lib
drwxr-xr-x. 2 root root         6 Apr 10  2018 lib64
drwxr-xr-x. 2 root root         6 Apr 10  2018 libexec
-rw-r--r--. 1 root root 666559924 Aug  7 07:04 mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
drwxr-xr-x. 2 root root         6 Apr 10  2018 sbin
drwxr-xr-x. 5 root root        49 Feb 25 19:38 share
drwxr-xr-x. 2 root root         6 Apr 10  2018 src
[root@localhost local]# tar -zxvf mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
mysql-5.7.36-linux-glibc2.12-x86_64/bin/myisam_ftdump
mysql-5.7.36-linux-glibc2.12-x86_64/bin/myisamchk
mysql-5.7.36-linux-glibc2.12-x86_64/bin/myisamlog
mysql-5.7.36-linux-glibc2.12-x86_64/bin/myisampack
mysql-5.7.36-linux-glibc2.12-x86_64/bin/mysql
mysql-5.7.36-linux-glibc2.12-x86_64/bin/mysql_client_test_embedded
mysql-5.7.36-linux-glibc2.12-x86_64/bin/mysql_config_editor
mysql-5.7.36-linux-glibc2.12-x86_64/bin/mysql_embedded
mysql-5.7.36-linux-glibc2.12-x86_64/bin/mysql_install_db
mysql-5.7.36-linux-glibc2.12-x86_64/bin/mysql_plugin
mysql-5.7.36-linux-glibc2.12-x86_64/bin/mysql_secure_installation
mysql-5.7.36-linux-glibc2.12-x86_64/bin/mysql_ssl_rsa_setup
mysql-5.7.36-linux-glibc2.12-x86_64/bin/mysql_tzinfo_to_sql
。。。。。。
[root@localhost local]# mv mysql-5.7.36-linux-glibc2.12-x86_64 mysql
[root@localhost local]# ll
total 650940
drwxr-xr-x. 2 root root       122 Apr 21 00:03 bin
drwxr-xr-x. 2 root root         6 Apr 10  2018 etc
drwxr-xr-x. 2 root root         6 Apr 10  2018 games
drwxr-xr-x. 2 root root        35 May 11 02:00 include
drwxr-xr-x. 2 root root         6 Apr 10  2018 lib
drwxr-xr-x. 2 root root         6 Apr 10  2018 lib64
drwxr-xr-x. 2 root root         6 Apr 10  2018 libexec
drwxr-xr-x. 9 root root       129 Aug  7 07:05 mysql
-rw-r--r--. 1 root root 666559924 Aug  7 07:04 mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
drwxr-xr-x. 2 root root         6 Apr 10  2018 sbin
drwxr-xr-x. 5 root root        49 Feb 25 19:38 share
drwxr-xr-x. 2 root root         6 Apr 10  2018 src
[root@localhost local]# rm -f mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root root 122 Apr 21 00:03 bin
drwxr-xr-x. 2 root root   6 Apr 10  2018 etc
drwxr-xr-x. 2 root root   6 Apr 10  2018 games
drwxr-xr-x. 2 root root  35 May 11 02:00 include
drwxr-xr-x. 2 root root   6 Apr 10  2018 lib
drwxr-xr-x. 2 root root   6 Apr 10  2018 lib64
drwxr-xr-x. 2 root root   6 Apr 10  2018 libexec
drwxr-xr-x. 9 root root 129 Aug  7 07:05 mysql
drwxr-xr-x. 2 root root   6 Apr 10  2018 sbin
drwxr-xr-x. 5 root root  49 Feb 25 19:38 share
drwxr-xr-x. 2 root root   6 Apr 10  2018 src
[root@localhost local]# chown -R mysql mysql/
[root@localhost local]# chgrp -R mysql mysql/
[root@localhost local]# cd mysql/
[root@localhost mysql]# mkdir data
[root@localhost mysql]# chown -R mysql:mysql data
[root@localhost mysql]# cd /etc/
[root@localhost etc]# ll
total 1420
drwxr-xr-x.  3 root root      101 Feb 25 19:43 abrt
-rw-r--r--.  1 root root       16 Feb 25 19:51 adjtime
-rw-r--r--.  1 root root     1529 Mar 31  2020 aliases
-rw-r--r--.  1 root root    12288 Feb 25 19:52 aliases.db
drwxr-xr-x.  3 root root       65 Feb 25 19:46 alsa
drwxr-xr-x.  2 root root     4096 Feb 25 19:51 alternatives
-rw-------.  1 root root      541 Aug  8  2019 anacrontab
-rw-r--r--.  1 root root       55 Aug  8  2019 asound.conf
-rw-r--r--.  1 root root        1 Oct 30  2018 at.deny
drwxr-x---.  3 root root       43 Feb 25 19:43 audisp
drwxr-x---.  3 root root       83 Feb 25 19:52 audit
-rw-r--r--.  1 root root    15137 Sep 30  2020 autofs.conf
-rw-------.  1 root root      232 Sep 30  2020 autofs_ldap_auth.conf
-rw-r--r--.  1 root root      795 Sep 30  2020 auto.master
drwxr-xr-x.  2 root root        6 Sep 30  2020 auto.master.d
-rw-r--r--.  1 root root      524 Sep 30  2020 auto.misc
-rwxr-xr-x.  1 root root     1260 Sep 30  2020 auto.net
-rwxr-xr-x.  1 root root      687 Sep 30  2020 auto.smb
drwxr-xr-x.  4 root root       71 Feb 25 19:46 avahi
。。。。。。
[root@localhost etc]# touch my.cnf
[root@localhost etc]# ll
total 1420
drwxr-xr-x.  3 root root      101 Feb 25 19:43 abrt
-rw-r--r--.  1 root root       16 Feb 25 19:51 adjtime
-rw-r--r--.  1 root root     1529 Mar 31  2020 aliases
-rw-r--r--.  1 root root    12288 Feb 25 19:52 aliases.db
drwxr-xr-x.  3 root root       65 Feb 25 19:46 alsa
drwxr-xr-x.  2 root root     4096 Feb 25 19:51 alternatives
-rw-------.  1 root root      541 Aug  8  2019 anacrontab
-rw-r--r--.  1 root root       55 Aug  8  2019 asound.conf
-rw-r--r--.  1 root root        1 Oct 30  2018 at.deny
drwxr-x---.  3 root root       43 Feb 25 19:43 audisp
drwxr-x---.  3 root root       83 Feb 25 19:52 audit
。。。。。。
[root@localhost etc]# pwd
/etc
[root@localhost etc]# cd /usr/local/mysql/
[root@localhost mysql]# ll
total 272
drwxr-xr-x.  2 mysql mysql   4096 Aug  7 07:05 bin
drwxr-xr-x.  2 mysql mysql      6 Aug  7 07:06 data
drwxr-xr-x.  2 mysql mysql     55 Aug  7 07:05 docs
drwxr-xr-x.  3 mysql mysql   4096 Aug  7 07:05 include
drwxr-xr-x.  5 mysql mysql    230 Aug  7 07:05 lib
-rw-r--r--.  1 mysql mysql 259199 Sep  6  2021 LICENSE
drwxr-xr-x.  4 mysql mysql     30 Aug  7 07:05 man
-rw-r--r--.  1 mysql mysql    566 Sep  6  2021 README
drwxr-xr-x. 28 mysql mysql   4096 Aug  7 07:05 share
drwxr-xr-x.  2 mysql mysql     90 Aug  7 07:05 support-files
[root@localhost mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --
2022-08-07 07:09:15 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2022-08-07 07:09:15 [ERROR]   The data directory needs to be specified.

[root@localhost mysql]# cd bin/
[root@localhost bin]# mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --
bash: mysql_install_db: command not found...

[root@localhost bin]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --
2022-08-07 07:09:40 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2022-08-07 07:09:40 [ERROR]   The data directory needs to be specified.

[root@localhost bin]# cd bi
-bash: cd: bi: No such file or directory
[root@localhost bin]# cd bin
-bash: cd: bin: No such file or directory
[root@localhost bin]# ll
total 1348160
-rwxr-xr-x. 1 mysql mysql   8147275 Sep  7  2021 innochecksum
-rwxr-xr-x. 1 mysql mysql    359769 Sep  7  2021 lz4_decompress
-rwxr-xr-x. 1 mysql mysql  10101581 Sep  7  2021 myisamchk
-rwxr-xr-x. 1 mysql mysql   9642658 Sep  7  2021 myisam_ftdump
-rwxr-xr-x. 1 mysql mysql   7539128 Sep  7  2021 myisamlog
-rwxr-xr-x. 1 mysql mysql   9769178 Sep  7  2021 myisampack
-rwxr-xr-x. 1 mysql mysql   7435495 Sep  7  2021 my_print_defaults
-rwxr-xr-x. 1 mysql mysql  10456480 Sep  7  2021 mysql
。。。。。。
[root@localhost bin]# ./mysqld --initialize --user=mysql
2022-08-07T14:10:55.428560Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-08-07T14:10:55.485143Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2022-08-07T14:10:55.549898Z 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: c0c72931-165a-11ed-b15d-000c290923cd.

2022-08-07T14:10:55.552919Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2022-08-07T14:10:56.502231Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.

2022-08-07T14:10:56.502306Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.

2022-08-07T14:10:56.504364Z 0 [Warning] CA certificate ca.pem is self signed.

2022-08-07T14:10:56.740944Z 1 [Note] A temporary password is generated for root@localhost: ?dV?_49?hc.f
[root@localhost bin]# pwd
/usr/local/mysql/bin
[root@localhost bin]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
-bash: bin/mysql_install_db: No such file or directory
[root@localhost bin]# ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
-bash: ./bin/mysql_install_db: No such file or directory
[root@localhost bin]# sh bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
sh: bin/mysql_install_db: No such file or directory
[root@localhost bin]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
2022-08-07 07:12:36 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2022-08-07 07:12:36 [ERROR]   The data directory '/usr/local/mysql/data' already exist and is not empty.

[root@localhost bin]# rm -rf /usr/local/mysql/data/
[root@localhost bin]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
2022-08-07 07:13:23 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2022-08-07 07:13:27 [WARNING] The bootstrap log isn't empty:
2022-08-07 07:13:27 [WARNING] 2022-08-07T14:13:23.279025Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2022-08-07T14:13:23.279659Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2022-08-07T14:13:23.279668Z 0 [Warning] Changed limits: table_open_cache: 407 (requested 2000)

[root@localhost bin]# cd ../
[root@localhost mysql]# ll
total 276
drwxr-xr-x.  2 mysql mysql   4096 Aug  7 07:05 bin
drwxr-x---.  5 mysql mysql   4096 Aug  7 07:13 data
drwxr-xr-x.  2 mysql mysql     55 Aug  7 07:05 docs
drwxr-xr-x.  3 mysql mysql   4096 Aug  7 07:05 include
drwxr-xr-x.  5 mysql mysql    230 Aug  7 07:05 lib
-rw-r--r--.  1 mysql mysql 259199 Sep  6  2021 LICENSE
drwxr-xr-x.  4 mysql mysql     30 Aug  7 07:05 man
-rw-r--r--.  1 mysql mysql    566 Sep  6  2021 README
drwxr-xr-x. 28 mysql mysql   4096 Aug  7 07:05 share
drwxr-xr-x.  2 mysql mysql     90 Aug  7 07:05 support-files
[root@localhost mysql]# cp ./support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# chown 777 my.cnf
chown: cannot access ‘my.cnf’: No such file or directory
[root@localhost mysql]# chown 777 /etc/my.cnf
[root@localhost mysql]# /etc/init.d/mysqld restart
 ERROR! MySQL server PID file could not be found!

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

2022-08-07T14:14:23.991592Z mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
 ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).

[root@localhost mysql]# mysql]# ps aux|grep mysql
bash: mysql]#: command not found...

[root@localhost mysql]# ps aux|grep mysql
root      14366  0.0  0.0 112808   964 pts/1    R+   07:15   0:00 grep --color=auto mysql
[root@localhost mysql]# kill -9 14366
-bash: kill: (14366) - No such process
[root@localhost mysql]# /usr/local/mysql/bin/mysqld_safe: line 198: 32684 Killed                  nohup /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=CDH-141.err --pid-file=/usr/local/mysql/data/CDH-141.pid --port=3323 < /dev/null > /dev/null 2>&1
[root@localhost mysql]# ps aux|grep mysql
root      14670  0.0  0.0 112808   968 pts/1    S+   07:15   0:00 grep --color=auto mysql
[root@localhost mysql]# /etc/init.d/mysqld restart
 ERROR! MySQL server PID file could not be found!

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

2022-08-07T14:15:57.588824Z mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
 ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).

[root@localhost mysql]# service mysqld start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.

2022-08-07T14:16:30.536032Z mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
 ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).

[root@localhost mysql]# cat /usr/local/mysql/data/localhost.localdomain.err
cat: /usr/local/mysql/data/localhost.localdomain.err: No such file or directory
[root@localhost mysql]# cd  /usr/local/mysql/data/
[root@localhost data]# ll
total 110660
-rw-r-----. 1 mysql mysql       56 Aug  7 07:13 auto.cnf
-rw-------. 1 mysql mysql     1676 Aug  7 07:13 ca-key.pem
-rw-r--r--. 1 mysql mysql     1112 Aug  7 07:13 ca.pem
-rw-r--r--. 1 mysql mysql     1112 Aug  7 07:13 client-cert.pem
-rw-------. 1 mysql mysql     1676 Aug  7 07:13 client-key.pem
-rw-r-----. 1 mysql mysql      436 Aug  7 07:13 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Aug  7 07:13 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Aug  7 07:13 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Aug  7 07:13 ib_logfile1
drwxr-x---. 2 mysql mysql     4096 Aug  7 07:13 mysql
drwxr-x---. 2 mysql mysql     8192 Aug  7 07:13 performance_schema
-rw-------. 1 mysql mysql     1676 Aug  7 07:13 private_key.pem
-rw-r--r--. 1 mysql mysql      452 Aug  7 07:13 public_key.pem
-rw-r--r--. 1 mysql mysql     1112 Aug  7 07:13 server-cert.pem
-rw-------. 1 mysql mysql     1680 Aug  7 07:13 server-key.pem
drwxr-x---. 2 mysql mysql     8192 Aug  7 07:13 sys
[root@localhost data]# chown -R mysql:mysql /var/lib/mysql
chown: cannot access ‘/var/lib/mysql’: No such file or directory
[root@localhost data]# mkdir -p /var//lib/mysql
[root@localhost data]# chown -R mysql:mysql /var/lib/mysql
[root@localhost data]# systemctl start mysql
Failed to start mysql.service: Unit not found.

[root@localhost data]# systemctl start mysqld
Failed to start mysqld.service: Unit not found.

[root@localhost data]# service mysqld start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.

 SUCCESS!

[root@localhost data]# chkconfig --level 35 mysqld on
[root@localhost data]# chkconfig --list mysqld

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.

      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@localhost data]# service mysqld status
 SUCCESS! MySQL running (16587)
[root@localhost data]# vim /etc/profile
[root@localhost data]# source /etc/profile
[root@localhost data]#  cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2022-08-07 07:13:23
SBjo&twpMd>K
[root@localhost data]# mysql -uroot -p
Enter password:
mysql: Character set 'utf8-mb4' is not a compiled character set and is not specified in the '/usr/local/mysql/share/charsets/Index.xml' file
mysql: Character set 'utf8-mb4' is not a compiled character set and is not specified in the '/usr/local/mysql/share/charsets/Index.xml' file
ERROR 2019 (HY000): Can't initialize character set utf8-mb4 (path: /usr/local/mysql/share/charsets/)
[root@localhost data]# vim /etc/my.cnf
[root@localhost data]# systemctl restart mysql
[root@localhost data]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost data]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 7
Server version: 5.7.36

Copyright (c) 2000, 2021, 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> set PASSWORD = PASSWORD('MGuoDu2022');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql>exit;
Bye

[root@localhost data]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.7.36 MySQL Community Server (GPL) Copyright (c) 2000, 2021, 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> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'MGuoDu2022' WITH GRANT OPTION; Query OK, 0 rows affected, 1 warning (0.06 sec) mysql> select host,user from user; ERROR 1046 (3D000): No database selected mysql> service mysqld restart mysql> exit; Bye [root@localhost data]# service mysqld restart Shutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS! [root@localhost data]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2022-08-07 06:50:58 PDT; 39min ago Docs: man:firewalld(1) Main PID: 696 (firewalld) Tasks: 2 Memory: 10.6M CGroup: /system.slice/firewalld.service └─696 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid Aug 07 06:50:57 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon... Aug 07 06:50:58 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon. Aug 07 06:50:58 localhost.localdomain firewalld[696]: WARNING: AllowZoneDrifting is enabled. This is considered an insec... now. Hint: Some lines were ellipsized, use -l to show in full. [root@localhost data]# [root@localhost data]# firewall-cmd --permanent --add-port=3506/tcp success [root@localhost data]# [root@localhost data]# firewall-cmd --reload success [root@localhost data]# vim /etc/my.cnf [root@localhost data]# systemctl restart mysql [root@localhost data]#

Original: https://www.cnblogs.com/JimmyThomas/p/16571278.html
Author: JimmyThomas
Title: Centos7环境使用Mysql离线安装包安装Mysql5.7

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/505060/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • JVM

    JVM 一、什么是JVM 定义 Java Virtual Machine,JAVA程序的运行环境(JAVA二进制字节码的运行环境) 好处 一次编写,到处运行 自动内存管理,垃圾回收…

    数据库 2023年6月16日
    0108
  • MySQL连接的建立与使用

    在 MYSQL的启动过程中,可以看到在 mysqld_main() 函数的最后调用了 mysqld_socket_acceptor->connection_event_loo…

    数据库 2023年6月9日
    0139
  • Vue 2.0 基础

    知识点 1.是一个MVVM框架 由MVC架构衍生,分为View(视图层)、ViewModel(数据视图层)、Model(数据层),MVVM 最标志性的特性就是 数据绑定,实现数据驱…

    数据库 2023年6月11日
    0151
  • go context详解

    Context通常被称为上下文,在go中,理解为goroutine的运行状态、现场,存在上下层goroutine context的传递,上层goroutine会把context传递…

    数据库 2023年6月9日
    0149
  • 实现一个简单的Database2(译文)

    前文回顾:实现一个简单的Database1(译文) 译注:cstsck在github维护了一个简单的、类似sqlite的数据库实现,通过这个简单的项目,可以很好的理解数据库是如何运…

    数据库 2023年6月11日
    0156
  • 事务的四大特性

    事务的四大特性 原子性(Atomicity):事务是不可分割的最小操作单元,要么全部成功,要么全部失败。 一致性(Consistency):事务完成时,必须使所有的数据都保持一致状…

    数据库 2023年6月11日
    0145
  • Mysql的读写分离中间件该怎么写?听我来说。

    网上有很多读写分离的中间件,像proxy,mycat等等,由于本人比较懒,懒得去读各种开源的东西,还是想造轮子来得快。 1、了解mysql通信协议,其中有分4.1之前和4.1版本的…

    数据库 2023年6月14日
    0170
  • 面试题: 字符串转整型 终结者

    随着代码手感增强, 想为这个问题写个终结者系列. 缅怀下曾经的自己. 我们审视下这个问题, 整数字符串转成整数. 那么意味着有效字符仅有 “+-0123456789&#…

    数据库 2023年6月9日
    0135
  • sed与awk命令

    1.1 sed命令语法 在看单个命令以前,需要回顾一下关于所有sed命令的两点语法。在上一个章中,我们介绍了其大部分内容。行地址对于任何命令都是可选的。它可以使一个模式,被描述为由…

    数据库 2023年6月14日
    0156
  • Golang并发编程——goroutine、channel、sync

    并发与并行 并发和并行是有区别的,并发不等于并行。 两个或多个事件在同一时间不同时间间隔发生。对应在Go中,就是指多个 goroutine 在单个CPU上的交替运行。 两个或者多个…

    数据库 2023年6月16日
    0101
  • 不要让“Clean Code”更难维护,请使用“Rule of Three”

    当人们试图将”代码整洁之道(Clean Code)”的原则应用于现有的代码库时,我经常会问这个问题。 我认为这是合情合理的。 当我们开始重构遗留代码时,通常…

    数据库 2023年6月14日
    0143
  • 需求评审,测试人员应该发挥怎样的价值?两分钟让你不再懵逼

    转载请注明出处❤️ 你好,我是测试蔡坨坨。 前些日与朋友聊天,谈及需求评审,作为测试人员,我们应该在需求评审会议上做些什么? 记得第一次参加需求评审,傻傻的过去坐着,然后听别人巴拉…

    数据库 2023年6月11日
    0135
  • 模板语法之传值取值

    模板语法之传值 变量相关使用:{{}}逻辑语法相关:{% %} 后端传值部分: def index(request): # &#x6A21;&#x7248;&amp…

    数据库 2023年6月14日
    0113
  • python 学习笔记(十二)–Django 基本知识点小结

    构造函数格式: 作用: 向客户端浏览器返回相应,同时携带响应体内容。 参数: –content:表示返回的内容。 –status_code:返回的HTTP响…

    数据库 2023年6月16日
    0121
  • Minio的安装与使用

    Minio的安装与使用 一、Minio介绍 MinIO 是在 Apache License v2.0 下发布的高性能对象存储. 就是说是个存东西的玩意,比较方便配好启动就能访问,也…

    数据库 2023年6月6日
    0141
  • 第十六章:接口

    本篇翻译自《Practical Go Lessons》 Chapter 16: Interfaces 1 你将在本章学到什么? 什么是类型接口? 如何定义接口。 “实现…

    数据库 2023年6月6日
    0142
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球