wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.32-linux-glibc2.17-x86_64-minimal.tar.xz
tar -xvf mysql-8.0.32-linux-glibc2.17-x86_64-minimal.tar.xz
mkdir /data/mysql
mkdir /data/mysql_data
mkdir /data/mysql/log

groupadd mysql
useradd -g mysql mysql

chown -R mysql:mysql /data
vim /etc/profile

加入环境变量
export PATH=$PATH:/data/mysql/bin:/data/mysql/lib
source /etc/profile

root@jyc:~# more /etc/my.cnf 
[client]
port=3306
socket=/data/mysql/mysql.sock
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
port=3306
user=mysql
socket=/data/mysql/mysql.sock
basedir=/data/mysql
datadir=/data/mysql_data
lower-case-table-names=1
default_authentication_plugin=mysql_native_password
innodb_buffer_pool_size=200M
slow_query_log=ON
slow_query_log_file=/data/mysql/log/slow.log
long_query_time=2
log_queries_not_using_indexes=off
max_connections=1000
innodb_flush_log_at_trx_commit=2
character_set_server=utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect=‘SET NAMES utf8mb4’
skip-character-set-client-handshake = true
skip-name-resolve
log-bin=/data/mysql_data/mysql-bin

#general_log = 1
#general_log_file= /data/mysql/log/mysql.log
#skip-grant-tables
#skip-log-bin

更多参考:https://www.modb.pro/db/574998


root@jyc:~# cat /etc/issue
Ubuntu 20.04.5 LTS \n \l

root@jyc:/data/mysql# ./bin/mysqld --user=mysql --basedir=/data/mysql --datadir=/data/mysql_data --initialize
2024-10-31T12:03:53.765030Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2024-10-31T12:03:53.765067Z 0 [System] [MY-013169] [Server] /data/mysql/bin/mysqld (mysqld 8.0.32) initializing of server in progress as process 4961
2024-10-31T12:03:53.781153Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-10-31T12:03:54.367106Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-10-31T12:03:55.578134Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: JV2MrrtC6k=A
root@jyc:/data/mysql# cp ./support-files/mysql.server /etc/init.d/mysql
root@jyc:/data/mysql# chmod +x /etc/init.d/mysql
root@jyc:/data/mysql# ps -ef|grep mysql
root        5006    4165  0 12:04 pts/1    00:00:00 grep --color=auto mysql
root@jyc:/data/mysql# /etc/init.d/mysql start
Starting mysql (via systemctl): mysql.service.
root@jyc:/data/mysql# ps -ef|grep mysql
root        5048       1  0 12:04 ?        00:00:00 /bin/sh /data/mysql/bin/mysqld_safe --datadir=/data/mysql_data --pid-file=/data/mysql_data/jyc.pid
mysql       5406    5048 10 12:04 ?        00:00:01 /data/mysql/bin/mysqld --basedir=/data/mysql --datadir=/data/mysql_data --plugin-dir=/data/mysql/lib/plugin --user=mysql --log-error=jyc.err --pid-file=/data/mysql_data/jyc.pid --socket=/data/mysql/mysql.sock --port=3306
root        5457    4165  0 12:04 pts/1    00:00:00 grep --color=auto mysql
root@jyc:/data/mysql# mysql -u root -p
mysql: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory
root@jyc:/data/mysql# /data/mysql/bin/mysql -u root -p
/data/mysql/bin/mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

root@jyc:~# netstat -tunlp|grep LISTEN

Command 'netstat' not found, but can be installed with:

apt install net-tools

root@jyc:~# apt install net-tools -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 mysql-community-client : Depends: libc6 (>= 2.34) but 2.31-0ubuntu9.9 is to be installed
                          Depends: libssl3 (>= 3.0.0~~alpha1) but it is not installable
                          Depends: libstdc++6 (>= 11) but 10.3.0-1ubuntu1~20.04 is to be installed
 mysql-community-client-core : Depends: libc6 (>= 2.34) but 2.31-0ubuntu9.9 is to be installed
                               Depends: libssl3 (>= 3.0.0~~alpha1) but it is not installable
                               Depends: libstdc++6 (>= 11) but 10.3.0-1ubuntu1~20.04 is to be installed
                               Depends: mysql-community-client-plugins (= 8.0.32-1ubuntu22.04) but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
root@jyc:~# apt remove mysql-community-client
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 mysql-community-client-core : Depends: libc6 (>= 2.34) but 2.31-0ubuntu9.9 is to be installed
                               Depends: libssl3 (>= 3.0.0~~alpha1) but it is not installable
                               Depends: libstdc++6 (>= 11) but 10.3.0-1ubuntu1~20.04 is to be installed
                               Depends: mysql-community-client-plugins (= 8.0.32-1ubuntu22.04) but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
root@jyc:~# apt remove mysql-community-client-core
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 mysql-community-client : Depends: libc6 (>= 2.34) but 2.31-0ubuntu9.9 is to be installed
                          Depends: libssl3 (>= 3.0.0~~alpha1) but it is not installable
                          Depends: libstdc++6 (>= 11) but 10.3.0-1ubuntu1~20.04 is to be installed
                          Depends: mysql-community-client-core (= 8.0.32-1ubuntu22.04) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
root@jyc:~# dpkg -r mysql-community-client
(Reading database ... 72105 files and directories currently installed.)
Removing mysql-community-client (8.0.32-1ubuntu22.04) ...
Processing triggers for man-db (2.9.1-1) ...
root@jyc:~# dpkg -r mysql-community-client-core
(Reading database ... 72082 files and directories currently installed.)
Removing mysql-community-client-core (8.0.32-1ubuntu22.04) ...
Processing triggers for man-db (2.9.1-1) ...
root@jyc:~# apt install net-tools -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  net-tools
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 196 kB of archives.
After this operation, 864 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 net-tools amd64 1.60+git20180626.aebd88e-1ubuntu1 [196 kB]
Fetched 196 kB in 20s (9,942 B/s)                                                                                                                                                                  
Selecting previously unselected package net-tools.
(Reading database ... 72070 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20180626.aebd88e-1ubuntu1_amd64.deb ...
Unpacking net-tools (1.60+git20180626.aebd88e-1ubuntu1) ...
Setting up net-tools (1.60+git20180626.aebd88e-1ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
root@jyc:~# which mysql
/data/mysql/bin/mysql
root@jyc:~# mysql -u root -p
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
root@jyc:~# find / -name libncurses.so.5
root@jyc:~# find / -name libncurses.so.*
/snap/core20/1611/usr/lib/x86_64-linux-gnu/libncurses.so.6
/snap/core20/1611/usr/lib/x86_64-linux-gnu/libncurses.so.6.2
/usr/lib/x86_64-linux-gnu/libncurses.so.6
/usr/lib/x86_64-linux-gnu/libncurses.so.6.2
root@jyc:~# apt install libncurses5
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libncurses5
root@jyc:~# apt install libncurses5*
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libncurses5-dev' for glob 'libncurses5*'
The following additional packages will be installed:
  libc-dev-bin libc6-dev libcrypt-dev libncurses-dev linux-libc-dev manpages-dev
Suggested packages:
  glibc-doc ncurses-doc
The following NEW packages will be installed:
  libc-dev-bin libc6-dev libcrypt-dev libncurses-dev libncurses5-dev linux-libc-dev manpages-dev
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,691 kB/6,401 kB of archives.
After this operation, 32.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Err:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libc-dev-bin amd64 2.31-0ubuntu9.9
  404  Not Found [IP: 185.125.190.81 80]
Ign:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-125.141
Err:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libc6-dev amd64 2.31-0ubuntu9.9
  404  Not Found [IP: 185.125.190.81 80]
Err:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-125.141                                                                                                 
  404  Not Found [IP: 185.125.190.81 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc-dev-bin_2.31-0ubuntu9.9_amd64.deb  404  Not Found [IP: 185.125.190.81 80]                                               
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_5.4.0-125.141_amd64.deb  404  Not Found [IP: 185.125.190.81 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6-dev_2.31-0ubuntu9.9_amd64.deb  404  Not Found [IP: 185.125.190.81 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
root@jyc:~# apt install libncurses5*
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libncurses5-dev' for glob 'libncurses5*'
The following additional packages will be installed:
  libc-dev-bin libc6-dev libcrypt-dev libncurses-dev linux-libc-dev manpages-dev
Suggested packages:
  glibc-doc ncurses-doc
The following NEW packages will be installed:
  libc-dev-bin libc6-dev libcrypt-dev libncurses-dev libncurses5-dev linux-libc-dev manpages-dev
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,691 kB/6,401 kB of archives.
After this operation, 32.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Err:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libc-dev-bin amd64 2.31-0ubuntu9.9
  404  Not Found [IP: 185.125.190.82 80]
Ign:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-125.141
Err:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libc6-dev amd64 2.31-0ubuntu9.9
  404  Not Found [IP: 185.125.190.82 80]
Err:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-125.141
  404  Not Found [IP: 185.125.190.82 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc-dev-bin_2.31-0ubuntu9.9_amd64.deb  404  Not Found [IP: 185.125.190.82 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_5.4.0-125.141_amd64.deb  404  Not Found [IP: 185.125.190.82 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6-dev_2.31-0ubuntu9.9_amd64.deb  404  Not Found [IP: 185.125.190.82 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
root@jyc:~# apt install libncurses5-dev -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libc-dev-bin libc6-dev libcrypt-dev libncurses-dev linux-libc-dev manpages-dev
Suggested packages:
  glibc-doc ncurses-doc
The following NEW packages will be installed:
  libc-dev-bin libc6-dev libcrypt-dev libncurses-dev libncurses5-dev linux-libc-dev manpages-dev
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,691 kB/6,401 kB of archives.
After this operation, 32.9 MB of additional disk space will be used.
Err:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libc-dev-bin amd64 2.31-0ubuntu9.9                                                                                                 
  404  Not Found [IP: 185.125.190.83 80]
Ign:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-125.141                                                                                                 
Err:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libc6-dev amd64 2.31-0ubuntu9.9                                                                                                    
  404  Not Found [IP: 185.125.190.83 80]
Err:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-125.141                                                                                                 
  404  Not Found [IP: 185.125.190.83 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc-dev-bin_2.31-0ubuntu9.9_amd64.deb  404  Not Found [IP: 185.125.190.83 80]                                               
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_5.4.0-125.141_amd64.deb  404  Not Found [IP: 185.125.190.83 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6-dev_2.31-0ubuntu9.9_amd64.deb  404  Not Found [IP: 185.125.190.83 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
root@jyc:~# apt install libncurses5-dev -y --fix-missing
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libc-dev-bin libc6-dev libcrypt-dev libncurses-dev linux-libc-dev manpages-dev
Suggested packages:
  glibc-doc ncurses-doc
The following NEW packages will be installed:
  libc-dev-bin libc6-dev libcrypt-dev libncurses-dev libncurses5-dev linux-libc-dev manpages-dev
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,691 kB/6,401 kB of archives.
After this operation, 32.9 MB of additional disk space will be used.
Err:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libc-dev-bin amd64 2.31-0ubuntu9.9                                                                                                 
  404  Not Found [IP: 185.125.190.82 80]
Ign:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-125.141                                                                                                 
Err:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libc6-dev amd64 2.31-0ubuntu9.9                                                                                                    
  404  Not Found [IP: 185.125.190.82 80]
Err:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 linux-libc-dev amd64 5.4.0-125.141                                                                                                 
  404  Not Found [IP: 185.125.190.82 80]
Unable to correct missing packages.
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc-dev-bin_2.31-0ubuntu9.9_amd64.deb  404  Not Found [IP: 185.125.190.82 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_5.4.0-125.141_amd64.deb  404  Not Found [IP: 185.125.190.82 80]
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6-dev_2.31-0ubuntu9.9_amd64.deb  404  Not Found [IP: 185.125.190.82 80]
E: Aborting install.
root@jyc:~# 
root@jyc:~# 
root@jyc:~# 
root@jyc:~# find / -name libncurses.so.*
/snap/core20/1611/usr/lib/x86_64-linux-gnu/libncurses.so.6
/snap/core20/1611/usr/lib/x86_64-linux-gnu/libncurses.so.6.2
/usr/lib/x86_64-linux-gnu/libncurses.so.6
/usr/lib/x86_64-linux-gnu/libncurses.so.6.2
root@jyc:~# ln -s /usr/lib/x86_64-linux-gnu/libncurses.so.6.2 /usr/lib/x86_64-linux-gnu/libncurses.so.5
root@jyc:~# mysql -u root -p
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
root@jyc:~# find / -name libtinfo.so.*
/snap/core20/1611/usr/lib/x86_64-linux-gnu/libtinfo.so.6
/snap/core20/1611/usr/lib/x86_64-linux-gnu/libtinfo.so.6.2
/usr/lib/x86_64-linux-gnu/libtinfo.so.6
/usr/lib/x86_64-linux-gnu/libtinfo.so.6.2
root@jyc:~# ln -s /usr/lib/x86_64-linux-gnu/libtinfo.so.6.2 /usr/lib/x86_64-linux-gnu/libtinfo.so.5
root@jyc:~# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32

Copyright (c) 2000, 2023, 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> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'abcd1234';
Query OK, 0 rows affected (0.00 sec)

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

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

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

mysql> exit
Bye
root@jyc:~# mysql -u root -pabcd1234
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, 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> 


mysql> select * from mysql.user where user='root' \G
*************************** 1. row ***************************
                    Host: %
                    User: root
             Select_priv: Y
             Insert_priv: Y
             Update_priv: Y
             Delete_priv: Y
             Create_priv: Y
               Drop_priv: Y
             Reload_priv: Y
           Shutdown_priv: Y
            Process_priv: Y
               File_priv: Y
              Grant_priv: Y
         References_priv: Y
              Index_priv: Y
              Alter_priv: Y
            Show_db_priv: Y
              Super_priv: Y
   Create_tmp_table_priv: Y
        Lock_tables_priv: Y
            Execute_priv: Y
         Repl_slave_priv: Y
        Repl_client_priv: Y
        Create_view_priv: Y
          Show_view_priv: Y
     Create_routine_priv: Y
      Alter_routine_priv: Y
        Create_user_priv: Y
              Event_priv: Y
            Trigger_priv: Y
  Create_tablespace_priv: Y
                ssl_type: 
              ssl_cipher: 0x
             x509_issuer: 0x
            x509_subject: 0x
           max_questions: 0
             max_updates: 0
         max_connections: 0
    max_user_connections: 0
                  plugin: mysql_native_password
   authentication_string: *4AD47E08DAE2BD4F0977EED5D23DC901359DF617
        password_expired: N
   password_last_changed: 2024-10-31 12:23:53
       password_lifetime: NULL
          account_locked: N
        Create_role_priv: Y
          Drop_role_priv: Y
  Password_reuse_history: NULL
     Password_reuse_time: NULL
Password_require_current: NULL
         User_attributes: NULL
1 row in set (0.00 sec)
 

root@jyc:~# systemctl status mysql
● mysql.service - LSB: start and stop MySQL
     Loaded: loaded (/etc/init.d/mysql; generated)
     Active: active (running) since Thu 2024-10-31 12:04:35 UTC; 29min ago
       Docs: man:systemd-sysv-generator(8)
    Process: 5015 ExecStart=/etc/init.d/mysql start (code=exited, status=0/SUCCESS)
      Tasks: 40 (limit: 9443)
     Memory: 379.4M
     CGroup: /system.slice/mysql.service
             ├─5048 /bin/sh /data/mysql/bin/mysqld_safe --datadir=/data/mysql_data --pid-file=/data/mysql_data/jyc.pid
             └─5406 /data/mysql/bin/mysqld --basedir=/data/mysql --datadir=/data/mysql_data --plugin-dir=/data/mysql/lib/plugin --user=mysql --log-error=jyc.err --pid-file=/data/mysql_data/jyc.pi>

Oct 31 12:04:33 jyc systemd[1]: Starting LSB: start and stop MySQL...
Oct 31 12:04:33 jyc mysql[5015]: Starting MySQL
Oct 31 12:04:33 jyc mysql[5015]: .
Oct 31 12:04:33 jyc mysql[5048]: Logging to '/data/mysql_data/jyc.err'.
Oct 31 12:04:35 jyc mysql[5015]: . *
Oct 31 12:04:35 jyc systemd[1]: Started LSB: start and stop MySQL.
root@jyc:~# more /etc/init.d/mysql
#!/bin/sh
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
# This file is public domain and comes with NO WARRANTY of any kind

# MySQL daemon start/stop script.

# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
# When this is done the mysql server will be started when the machine is
# started and shut down when the systems goes down.

# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 64 36
# description: A very fast and reliable SQL database engine.

# Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: mysql
# Required-Start: $local_fs $network $remote_fs
# Should-Start: ypbind nscd ldap ntpd xntpd
# Required-Stop: $local_fs $network $remote_fs
# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop MySQL
# Description: MySQL is a very fast and reliable SQL database engine.
### END INIT INFO
 
# If you install MySQL on some other places than /usr/local/mysql, then you
# have to do one of the following things for this script to work:
#
# - Run this script from within the MySQL installation directory
# - Create a /etc/my.cnf file with the following information:
#   [mysqld]
#   basedir=<path-to-mysql-installation-directory>
# - Add the above to any other configuration file (for example ~/.my.ini)
#   and copy my_print_defaults to /usr/bin
# - Add the path to the mysql-installation-directory to the basedir variable
#   below.
#
# If you want to affect other MySQL variables, you should make your changes
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.

# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.

basedir=
datadir=

# Default value, in seconds, afterwhich the script should timeout waiting
# for server start. 
# Value here is overriden by value in my.cnf. 
# 0 means don't wait at all
# Negative numbers mean to wait indefinitely
service_startup_timeout=900

# Lock directory for RedHat / SuSE.
lockdir='/var/lock/subsys'
lock_file_path="$lockdir/mysql"

# The following variables are only set for letting mysql.server find things.

# Set some defaults
mysqld_pid_file_path=
if test -z "$basedir"
then
  basedir=/usr/local/mysql
  bindir=/usr/local/mysql/bin
  if test -z "$datadir"
  then
root@jyc:~# systemctl stop mysql
root@jyc:~# systemctl start mysql
root@jyc:~# mysql -u root -pabcd1234
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> exit
Bye
root@jyc:~# ps -ef|grep mysql
root        6831       1  0 12:35 ?        00:00:00 /bin/sh /data/mysql/bin/mysqld_safe --datadir=/data/mysql_data --pid-file=/data/mysql_data/jyc.pid
mysql       7190    6831  5 12:35 ?        00:00:01 /data/mysql/bin/mysqld --basedir=/data/mysql --datadir=/data/mysql_data --plugin-dir=/data/mysql/lib/plugin --user=mysql --log-error=jyc.err --pid-file=/data/mysql_data/jyc.pid --socket=/data/mysql/mysql.sock --port=3306
root        7245    5850  0 12:35 pts/0    00:00:00 grep --color=auto mysql
root@jyc:~# which mysql
/data/mysql/bin/mysql
root@jyc:~# cat /etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "${PS1-}" ]; then
  if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi
export PATH=$PATH:/data/mysql/bin:/data/mysql/lib
 

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐