[root@bogon data]# cd /data/mysql
[root@bogon mysql]# ll
总用量 308
drwxr-xr-x. 2 7161 31415 4096 7月 13 08:22 bin
drwxr-xr-x. 2 7161 31415 4096 7月 13 08:22 docs
drwxr-xr-x. 3 7161 31415 4096 7月 13 08:22 include
drwxr-xr-x. 6 7161 31415 4096 7月 13 08:22 lib
-rw-r--r--. 1 7161 31415 282186 7月 13 03:15 LICENSE
drwxr-xr-x. 4 7161 31415 4096 7月 13 08:22 man
-rw-r--r--. 1 7161 31415 666 7月 13 03:15 README
drwxr-xr-x. 28 7161 31415 4096 7月 13 08:22 share
drwxr-xr-x. 2 7161 31415 4096 7月 13 08:22 support-files
[root@bogon mysql]# cd bin/
[root@bogon bin]# ./mysqld --initialize-insecure --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data
2024-07-24T06:01:11.598068Z 0 [Warning] [MY-011070] [Server] 'binlog_format' is deprecated and will be removed in a future release.
2024-07-24T06:01:11.598077Z 0 [Warning] [MY-011068] [Server] The syntax 'expire-logs-days' is deprecated and will be removed in a future release. Please use binlog_expire_logs_seconds instead.
2024-07-24T06:01:11.598203Z 0 [System] [MY-013169] [Server] /data/mysql/bin/mysqld (mysqld 8.0.39) initializing of server in progress as process 4353
2024-07-24T06:01:11.607885Z 0 [Warning] [MY-013907] [InnoDB] Deprecated configuration parameters innodb_log_file_size and/or innodb_log_files_in_group have been used to compute innodb_redo_log_capacity=1073741824. Please use innodb_redo_log_capacity instead.
2024-07-24T06:01:11.610050Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-07-24T06:01:17.171717Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-07-24T06:01:20.161187Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@bogon bin]# service mysqld start
Starting MySQL.Logging to '/data/mysql/data/bogon.err'.
...... SUCCESS!
[root@bogon bin]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.39 MySQL Community Server - GPL
Copyright (c) 2000, 2024, 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 '123!';
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
[root@bogon bin]# mysql -uroot -p123!
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.39 MySQL Community Server - GPL
Copyright (c) 2000, 2024, 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> 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>
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> exit
Bye
[root@bogon bin]# service mysqld restart
Shutting down MySQL... SUCCESS!
Starting MySQL....... SUCCESS!
[root@bogon bin]# mysql -uroot -p123!