[root@BigWoody001 my.cnf.d]# cd /app/software/
[root@BigWoody001 software]# ls
mysql  nginxkey  ollama  redis  redis-7.0.0  redis-7.0.0.tar.gz
[root@BigWoody001 software]# cd mysql
[root@BigWoody001 mysql]# ls
data  mysql57-community-release-el7.rpm  mysql80-community-release-el7-3.noarch.rpm  mysql80-community-release-el7-3.noarch.rpm.1
[root@BigWoody001 mysql]# yum install -y mysql80-community-release-el7-3.noarch.rpm
Last metadata expiration check: 3:10:15 ago on Wed 26 Feb 2025 01:18:24 PM CST.
Dependencies resolved.
=============================================================================================================================================================================================================================================================
 Package                                                                   Architecture                                           Version                                                 Repository                                                    Size
=============================================================================================================================================================================================================================================================
Installing:
 mysql80-community-release                                                 noarch                                                 el7-3                                                   @commandline                                                  25 k

Transaction Summary
=============================================================================================================================================================================================================================================================
Install  1 Package

Total size: 25 k
Installed size: 31 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                                     1/1
  Installing       : mysql80-community-release-el7-3.noarch                                                                                                                                                                                              1/1
  Verifying        : mysql80-community-release-el7-3.noarch                                                                                                                                                                                              1/1

Installed:
  mysql80-community-release-el7-3.noarch

Complete!
[root@BigWoody001 mysql]#

 

 

[root@BigWoody001 mysql]# yum -y install mysql-community-server
Last metadata expiration check: 0:00:39 ago on Wed 26 Feb 2025 04:28:49 PM CST.
Dependencies resolved.
=============================================================================================================================================================================================================================================================
 Package                                                                  Architecture                                     Version                                                         Repository                                                   Size
=============================================================================================================================================================================================================================================================
Installing:
 mysql-community-server                                                   x86_64                                           8.0.41-1.el7                                                    mysql80-community                                            65 M
Installing dependencies:
 compat-openssl10                                                         x86_64                                           1:1.0.2o-4.0.1.al8                                              alinux3-updates                                             1.1 M
 mysql-community-client                                                   x86_64                                           8.0.41-1.el7                                                    mysql80-community                                            16 M
 mysql-community-client-plugins                                           x86_64                                           8.0.41-1.el7                                                    mysql80-community                                           3.5 M
 mysql-community-common                                                   x86_64                                           8.0.41-1.el7                                                    mysql80-community                                           666 k
 mysql-community-icu-data-files                                           x86_64                                           8.0.41-1.el7                                                    mysql80-community                                           2.2 M
 mysql-community-libs                                                     x86_64                                           8.0.41-1.el7                                                    mysql80-community                                           1.5 M

Transaction Summary
=============================================================================================================================================================================================================================================================
Install  7 Packages

Total download size: 90 M
Installed size: 419 M
Downloading Packages:
(1/7): compat-openssl10-1.0.2o-4.0.1.al8.x86_64.rpm                                                                                                                                                                           23 MB/s | 1.1 MB     00:00
(2/7): mysql-community-common-8.0.41-1.el7.x86_64.rpm                                                                                                                                                                        496 kB/s | 666 kB     00:01
(3/7): mysql-community-client-plugins-8.0.41-1.el7.x86_64.rpm                                                                                                                                                                1.9 MB/s | 3.5 MB     00:01
(4/7): mysql-community-icu-data-files-8.0.41-1.el7.x86_64.rpm                                                                                                                                                                3.6 MB/s | 2.2 MB     00:00
(5/7): mysql-community-libs-8.0.41-1.el7.x86_64.rpm                                                                                                                                                                          5.8 MB/s | 1.5 MB     00:00
(6/7): mysql-community-client-8.0.41-1.el7.x86_64.rpm                                                                                                                                                                        3.2 MB/s |  16 MB     00:05
(7/7): mysql-community-server-8.0.41-1.el7.x86_64.rpm                                                                                                                                                                         10 MB/s |  65 MB     00:06
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                                         11 MB/s |  90 MB     00:08
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                                     1/1
  Installing       : compat-openssl10-1:1.0.2o-4.0.1.al8.x86_64                                                                                                                                                                                          1/7
  Running scriptlet: compat-openssl10-1:1.0.2o-4.0.1.al8.x86_64                                                                                                                                                                                          1/7
  Installing       : mysql-community-client-plugins-8.0.41-1.el7.x86_64                                                                                                                                                                                  2/7
  Installing       : mysql-community-common-8.0.41-1.el7.x86_64                                                                                                                                                                                          3/7
  Installing       : mysql-community-libs-8.0.41-1.el7.x86_64                                                                                                                                                                                            4/7
  Running scriptlet: mysql-community-libs-8.0.41-1.el7.x86_64                                                                                                                                                                                            4/7
  Installing       : mysql-community-client-8.0.41-1.el7.x86_64                                                                                                                                                                                          5/7
  Installing       : mysql-community-icu-data-files-8.0.41-1.el7.x86_64                                                                                                                                                                                  6/7
  Running scriptlet: mysql-community-server-8.0.41-1.el7.x86_64                                                                                                                                                                                          7/7
  Installing       : mysql-community-server-8.0.41-1.el7.x86_64                                                                                                                                                                                          7/7
  Running scriptlet: mysql-community-server-8.0.41-1.el7.x86_64                                                                                                                                                                                          7/7
  Verifying        : compat-openssl10-1:1.0.2o-4.0.1.al8.x86_64                                                                                                                                                                                          1/7
  Verifying        : mysql-community-client-8.0.41-1.el7.x86_64                                                                                                                                                                                          2/7
  Verifying        : mysql-community-client-plugins-8.0.41-1.el7.x86_64                                                                                                                                                                                  3/7
  Verifying        : mysql-community-common-8.0.41-1.el7.x86_64                                                                                                                                                                                          4/7
  Verifying        : mysql-community-icu-data-files-8.0.41-1.el7.x86_64                                                                                                                                                                                  5/7
  Verifying        : mysql-community-libs-8.0.41-1.el7.x86_64                                                                                                                                                                                            6/7
  Verifying        : mysql-community-server-8.0.41-1.el7.x86_64                                                                                                                                                                                          7/7

Installed:
  compat-openssl10-1:1.0.2o-4.0.1.al8.x86_64     mysql-community-client-8.0.41-1.el7.x86_64     mysql-community-client-plugins-8.0.41-1.el7.x86_64     mysql-community-common-8.0.41-1.el7.x86_64     mysql-community-icu-data-files-8.0.41-1.el7.x86_64
  mysql-community-libs-8.0.41-1.el7.x86_64       mysql-community-server-8.0.41-1.el7.x86_64

Complete!
[root@BigWoody001 mysql]#

 

 

[root@BigWoody001 data]# vi /etc/my.cnf

 

第一次安装完成查看root默认密码
在cat /var/log/mysqld.log中查看
 
vim /etc/my.cnf,在[mysqld]下追加skip-grant-tables
重启:systemctl restart mysqld,然后用mysql命令直接登录
mysql> use mysql;
mysql> update user set authentication_string='' where user='root';
然后退出mysql,将skip-grant-tables注释掉,再重启mysql
登录mysql -uroot --connect-expired-password
修改默认密码:alter user user() identified by ‘aaaaaa’;


[root@BigWoody001 data]# systemctl restart mysqld
[root@BigWoody001 data]# mysql -hlocalhost -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.41 MySQL Community Server - GPL

Copyright (c) 2000, 2025, 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> update user set authentication_string='' where user='root';
ERROR 1046 (3D000): No database selected
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 authentication_string='' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> exit
Bye
[root@BigWoody001 data]# vi /etc/my.cnf
[root@BigWoody001 data]# systemctl restart mysqld
[root@BigWoody001 data]# mysql -uroot --connect-expired-password
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.41

Copyright (c) 2000, 2025, 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 user() identified by  '1Qasw2.ed';
Query OK, 0 rows affected (0.01 sec)

mysql> select user,host from mysql.user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+
4 rows in set (0.01 sec)

mysql>

[root@BigWoody001 data]# mysql -uroot -p1Qasw2.ed
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.41 MySQL Community Server - GPL

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

 

 

 

[root@BigWoody001 supervisor]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password

datadir=/app/software/mysql/data
socket=/var/lib/mysql/mysql.sock
character_set_server=utf8
default-storage-engine=INNODB
symbolic-links=0
port=9000
lower_case_table_names=1
#skip-grant-tables

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#skip-grant-tables
[mysql]
socket=/var/lib/mysql/mysql.sock
[client]
socket=/var/lib/mysql/mysql.sock
[mysqladmin]
socket=/var/lib/mysql/mysql.sock
[mysqldump]
socket=/var/lib/mysql/mysql.sock
[root@BigWoody001 supervisor]#

 

 

 

 

 

 

 

如果是windows

my.ini

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录 ----------是你的文件路径-------------
basedir=D:\\work\\software\\mysql-8.4.4-winx64
# 设置mysql数据库的数据的存放目录 ---------是你的文件路径data文件夹自行创建
datadir=D:\\work\\software\\mysql-8.4.4-winx64\\data
log-error=D:\\work\\software\\mysql-8.4.4-winx64\\log
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
#default_authentication_plugin=mysql_native_password
mysql_native_password=ON
#禁用sqlmode模式
sql_mode=''

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4

 

posted on 2025-02-26 17:52  woody.wu  阅读(37)  评论(0)    收藏  举报