【MySQL】install mysql 8.0 on centos 7.5 via yum

[root@wallet01 ~]# cat >> /etc/hosts <<EOF
192.168.1.201   wallet01
EOF

[root@wallet01 ~]# useradd mysql
[root@wallet01 ~]# id mysql
uid=500(mysql) gid=500(mysql) groups=500(mysql)

[root@wallet01 ~]# cat >> /etc/security/limits.conf <<EOF
mysql            soft    nproc          4096
mysql            hard    nproc          65535
mysql            soft    nofile         4096
mysql            hard    nofile         65535
EOF

[root@wallet01 ~]# yum install -y libaio yum-utils
[root@wallet01 ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm
[root@wallet01 ~]# yum-config-manager --disable mysql57-community
[root@wallet01 ~]# yum-config-manager --enable mysql80-community

[root@wallet01 ~]# yum repolist all | grep mysql 

[root@wallet01 ~]# yum install -y mysql-community-server

[root@wallet01 ~]# vim /etc/my.cnf
[mysqld]
user = mysql
port = 3306
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error = mysqld_error.log
log_timestamps = system
default_time_zone = "+8:00"
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci

server_id = 201
log_bin = mysql_bin
binlog_format = row
sync_binlog = 1
binlog_cache_size = 16M
max_binlog_cache_size = 4G
max_binlog_size = 128M
binlog_row_image = full
binlog_expire_logs_seconds = 604800

wait_timeout=43200  
interactive_timeout=43200

max_allowed_packet = 128M

tmp_table_size = 256M
max_heap_table_size = 256M

max_connections = 500
max_connect_errors = 10000
slow_query_log = 1
long_query_time = 5
slow_query_log_file = mysqld_slow.log

transaction_isolation = READ-COMMITTED

innodb_buffer_pool_size = 2G
innodb_buffer_pool_instances = 2
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_log_buffer_size = 16M
innodb_data_file_path=ibdata1:2G;ibdata2:2G:autoextend

[mysql]
default-character-set = utf8mb4

[root@wallet01 ~]# mysqld --initialize-insecure

[root@wallet01 ~]# systemctl start mysqld.service

[root@wallet01 ~]# systemctl status mysqld.service

[root@wallet01 ~]# netstat -tunlp | grep mysqld
tcp6       0      0 :::33060                :::*                    LISTEN      31718/mysqld        
tcp6       0      0 :::3306                 :::*                    LISTEN      31718/mysqld 

[root@wallet01 ~]# mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: n

##修改root密碼
Please set the password for root here.

New password: 

Re-enter new password: 
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

##刪除匿名用戶
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

##禁止root遠程登錄
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

##刪除測試庫
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

##刷新權限
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 

[root@wallet01 ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.22 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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> select version();
+-----------+
| version() |
+-----------+
| 8.0.22    |
+-----------+
1 row in set (0.00 sec)


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章