FreeBSD 14
Sponsored Link

MySQL 8.0 : Install2024/09/03

 

Install MySQL to configure Database Server.

[1] Install and start MySQL.
root@dlp:~ #
pkg install -y mysql80-server
root@dlp:~ #
service mysql-server enable

mysql enabled in /etc/rc.conf
root@dlp:~ #
service mysql-server start

Starting mysql.
[2] Initial verification for MySQL.
For MySQL 8, anonymous users, root login remotely, test databases are disabled by default, so it does not need to run [mysql_secure_installation].
root@dlp:~ #
mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.35 Source distribution

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.

# authentication method of root user is [auth_socket]
root@localhost [(none)]> select user,host,plugin from mysql.user; 
+------------------+-----------+-----------------------+
| user             | host      | plugin                |
+------------------+-----------+-----------------------+
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session    | localhost | caching_sha2_password |
| mysql.sys        | localhost | caching_sha2_password |
| root             | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
4 rows in set (0.00 sec)

# default charset
root@localhost [(none)]> show variables like "chara%"; 
+--------------------------+----------------------------------+
| Variable_name            | Value                            |
+--------------------------+----------------------------------+
| character_set_client     | utf8mb4                          |
| character_set_connection | utf8mb4                          |
| character_set_database   | utf8mb4                          |
| character_set_filesystem | binary                           |
| character_set_results    | utf8mb4                          |
| character_set_server     | utf8mb4                          |
| character_set_system     | utf8mb3                          |
| character_sets_dir       | /usr/local/share/mysql/charsets/ |
+--------------------------+----------------------------------+
8 rows in set (0.00 sec)

# databases
root@localhost [(none)]> show databases; 
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

# to enable password validation that is run with [mysql_secure_installation],
# set like follows
# * to disable it, run [uninstall component ***]
root@localhost [(none)]> install component 'file://component_validate_password'; 
Query OK, 0 rows affected (0.01 sec)

root@localhost [(none)]> show variables like 'validate_password%'; 
+-------------------------------------------------+--------+
| Variable_name                                   | Value  |
+-------------------------------------------------+--------+
| validate_password.changed_characters_percentage | 0      |
| validate_password.check_user_name               | ON     |
| validate_password.dictionary_file               |        |
| validate_password.length                        | 8      |
| validate_password.mixed_case_count              | 1      |
| validate_password.number_count                  | 1      |
| validate_password.policy                        | MEDIUM |
| validate_password.special_char_count            | 1      |
+-------------------------------------------------+--------+
8 rows in set (0.00 sec)

# * to change validation policy parameters, 
# set parameters under the [mysqld] section in [/usr/local/etc/mysql/my.cnf]
# ex. validate_password.policy=LOW


# create test database
root@localhost [(none)]> create database test_database; 
Query OK, 1 row affected (0.11 sec)

# create test table on test database
root@localhost [(none)]> create table test_database.test_table (id int, name varchar(50), address varchar(50), primary key (id)); 
Query OK, 0 rows affected (0.42 sec)

# insert data to test table
root@localhost [(none)]> insert into test_database.test_table(id, name, address) values("001", "FreeBSD", "Hiroshima"); 
Query OK, 1 row affected (0.04 sec)

# show test table
root@localhost [(none)]> select * from test_database.test_table; 
+----+---------+-----------+
| id | name    | address   |
+----+---------+-----------+
|  1 | FreeBSD | Hiroshima |
+----+---------+-----------+
1 row in set (0.00 sec)

# delete test database
root@localhost [(none)]> drop database test_database; 
Query OK, 1 row affected (0.27 sec)

root@localhost [(none)]> exit
Bye
Matched Content