CentOS Series Notes (2)

Install and deploy MySQL 5.7.25

Deploy and configure the MySQL 5725

1st remove the MySQL and mariadb which have been installed ,and also the configure files

[googlebigtable@localhost ~]$ su root
Password:
[root@localhost googlebigtable]# rpm -qa | grep mysql
[root@localhost googlebigtable]# rpm -qa | grep mari
mariadb-libs-5.5.60-1.el7_5.x86_64
marisa-0.2.4-4.el7.x86_64
[root@localhost googlebigtable]# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
[root@localhost googlebigtable]# rpm -qa | grep mari
marisa-0.2.4-4.el7.x86_64
[root@localhost googlebigtable]# ls / | grep my
[root@localhost googlebigtable]# ls / | grep my.cnf
[root@localhost googlebigtable]# find / -name mysql|xargs rm -r

2nd deploy the MySQL 5725

[root@localhost googlebigtable]# pwd -P
/home/googlebigtable
[root@localhost googlebigtable]# ls -F
Desktop/ Documents/ Downloads/ Music/ Pictures/ Public/ temp/ Templates/ Videos/
[root@localhost googlebigtable]#
[root@localhost googlebigtable]# tar -xzvf /mnt/hgfs/迅雷下载/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
mysql-5.7.25-linux-glibc2.12-x86_64/bin/myisam_ftdump
mysql-5.7.25-linux-glibc2.12-x86_64/bin/myisamchk
mysql-5.7.25-linux-glibc2.12-x86_64/bin/myisamlog
mysql-5.7.25-linux-glibc2.12-x86_64/bin/myisampack
mysql-5.7.25-linux-glibc2.12-x86_64/bin/mysql
.....................................................................................................................................................
mysql-5.7.25-linux-glibc2.12-x86_64/support-files/mysql.server
mysql-5.7.25-linux-glibc2.12-x86_64/docs/INFO_BIN
mysql-5.7.25-linux-glibc2.12-x86_64/docs/INFO_SRC
[root@localhost googlebigtable]#

Configure the mysql 5725

[root@localhost local]# pwd -P
/usr/local
[root@localhost local]# ls -F
bin/ etc/ games/ include/ lib/ lib64/ libexec/ mysql-5.7.25-linux-glibc2.12-x86_64/ sbin/ share/ src/
[root@localhost local]# mv mysql-5.7.25-linux-glibc2.12-x86_64/ mysql
[root@localhost local]# ls -F
bin/ etc/ games/ include/ lib/ lib64/ libexec/ mysql/ sbin/ share/ src/
[root@localhost local]# groupadd mysql
[root@localhost local]# useradd -g mysql mysql
[root@localhost local]# id mysql
uid=1001(mysql) gid=1001(mysql) groups=1001(mysql)
[root@localhost local]# chown -R mysql mysql
[root@localhost local]# chgrp -R mysql mysql
[root@localhost local]# cd mysql/
[root@localhost mysql]# ls -F
bin/ COPYING docs/ include/ lib/ man/ README share/ support-files/
[root@localhost mysql]# mkdir data
[root@localhost mysql]# chown -R mysql:mysql data
[root@localhost mysql]# ls -F
bin/ COPYING data/ docs/ include/ lib/ man/ README share/ support-files/
[root@localhost mysql]# ll
total 56
drwxr-xr-x. 2 mysql mysql 4096 Apr 13 06:26 bin
-rw-r--r--. 1 mysql mysql 17987 Dec 21 2018 COPYING
drwxr-xr-x. 2 mysql mysql 4096 Apr 13 06:31 data
drwxr-xr-x. 2 mysql mysql 4096 Apr 13 06:27 docs
drwxr-xr-x. 3 mysql mysql 4096 Apr 13 06:26 include
drwxr-xr-x. 5 mysql mysql 4096 Apr 13 06:27 lib
drwxr-xr-x. 4 mysql mysql 4096 Apr 13 06:26 man
-rw-r--r--. 1 mysql mysql 2478 Dec 21 2018 README
drwxr-xr-x. 28 mysql mysql 4096 Apr 13 06:27 share
drwxr-xr-x. 2 mysql mysql 4096 Apr 13 06:27 support-files
[root@localhost mysql]# touch my.conf
[root@localhost mysql]# ls -F
bin/ COPYING data/ docs/ include/ lib/ man/ my.conf README share/ support-files/
[root@localhost mysql]# gedit my.conf

(gedit:23960): GLib-GIO-CRITICAL **: 06:44:04.504: g_dbus_proxy_new_sync: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(gedit:23960): dconf-WARNING **: 06:44:04.552: failed to commit changes to dconf: The connection is closed

(gedit:23960): dconf-WARNING **: 06:44:04.559: failed to commit changes to dconf: The connection is closed
Error creating proxy: The connection is closed (g-io-error-quark, 18)
Error creating proxy: The connection is closed (g-io-error-quark, 18)
Error creating proxy: The connection is closed (g-io-error-quark, 18)
Error creating proxy: The connection is closed (g-io-error-quark, 18)
Error creating proxy: The connection is closed (g-io-error-quark, 18)

(gedit:23960): dconf-WARNING **: 06:44:04.837: failed to commit changes to dconf: The connection is closed

(gedit:23960): dconf-WARNING **: 06:44:04.838: failed to commit changes to dconf: The connection is closed

(gedit:23960): dconf-WARNING **: 06:44:04.838: failed to commit changes to dconf: The connection is closed

(gedit:23960): WARNING : 06:44:36.720: Set document metadata failed: Setting attribute metadata::gedit-spell-language not supported

(gedit:23960): WARNING : 06:44:36.721: Set document metadata failed: Setting attribute metadata::gedit-encoding not supported

(gedit:23960): WARNING : 06:44:37.389: Set document metadata failed: Setting attribute metadata::gedit-spell-language not supported

(gedit:23960): WARNING : 06:44:37.389: Set document metadata failed: Setting attribute metadata::gedit-encoding not supported

(gedit:23960): WARNING : 06:44:37.611: Set document metadata failed: Setting attribute metadata::gedit-spell-language not supported

(gedit:23960): WARNING : 06:44:37.612: Set document metadata failed: Setting attribute metadata::gedit-encoding not supported

(gedit:23960): WARNING : 06:44:40.983: Set document metadata failed: Setting attribute metadata::gedit-position not supported

(gedit:23960): dconf-WARNING **: 06:44:40.990: failed to commit changes to dconf: The connection is closed
[root@localhost mysql]# cat -n my.conf
1 [mysql]
2 socket=/var/lib/mysql/mysql.sock
3 # set mysql client default chararter
4 default-character-set=utf8
5
6 [mysqld]
7 socket=/var/lib/mysql/mysql.sock
8 # set mysql server port
9 port = 3306
10 # set mysql install base dir
11 basedir=/usr/local/mysql
12 # set the data store dir
13 datadir=/usr/local/mysql/data
14 # set the number of allow max connnection
15 max_connections=200
16 # set server charactre default encoding
17 character-set-server=utf8
18 # the storage engine
19 default-storage-engine=INNODB
20 lower_case_table_names=1
21 max_allowed_packet=16M
22 explicit_defaults_for_timestamp=true
23
24 [mysql.server]
25 user=mysql
26 basedir=/usr/local/mysql
[root@localhost mysql]#
[root@localhost mysql]# ls -F
bin/ COPYING data/ docs/ include/ lib/ man/ my.conf README share/ support-files/
[root@localhost mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
2020-04-13 06:52:51 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2020-04-13 06:52:53 [WARNING] The bootstrap log isn't empty:
2020-04-13 06:52:53 [WARNING] 2020-04-13T10:52:51.633949Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2020-04-13T10:52:51.634516Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2020-04-13T10:52:51.634523Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

[root@localhost mysql]# cp ./support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# chmod 777 my.conf
[root@localhost mysql]# ll
total 60
drwxr-xr-x. 2 mysql mysql 4096 Apr 13 06:26 bin
-rw-r--r--. 1 mysql mysql 17987 Dec 21 2018 COPYING
drwxr-xr-x. 5 mysql mysql 4096 Apr 13 06:52 data
drwxr-xr-x. 2 mysql mysql 4096 Apr 13 06:27 docs
drwxr-xr-x. 3 mysql mysql 4096 Apr 13 06:26 include
drwxr-xr-x. 5 mysql mysql 4096 Apr 13 06:27 lib
drwxr-xr-x. 4 mysql mysql 4096 Apr 13 06:26 man
-rwxrwxrwx. 1 root root 611 Apr 13 06:44 my.conf
-rw-r--r--. 1 mysql mysql 2478 Dec 21 2018 README
drwxr-xr-x. 28 mysql mysql 4096 Apr 13 06:27 share
drwxr-xr-x. 2 mysql mysql 4096 Apr 13 06:27 support-files
[root@localhost mysql]# chmod +x /etc/init.d/mysqld
[root@localhost mysql]# /etc/init.d/mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
SUCCESS!
[root@localhost mysql]# ps -aux | grep mysql
root 24239 0.0 0.0 113312 1636 pts/0 S 06:55 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/localhost.localdomain.pid
mysql 24324 1.1 4.4 1119460 171120 pts/0 Sl 06:55 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/usr/local/mysql/data/localhost.localdomain.pid
root 24368 0.0 0.0 112708 976 pts/0 S+ 06:55 0:00 grep --color=auto mysql
[root@localhost mysql]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@localhost mysql]#
[root@localhost mysql]# chkconfig mysqld on
[root@localhost mysql]# chkconfig --list mysqld

Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.

  If you want to list systemd services use 'systemctl list-unit-files'.
  To see services enabled on particular target use
  'systemctl list-dependencies [target]'.

mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost mysql]# service mysqld status
SUCCESS! MySQL running (24490)
[root@localhost mysql]#
[root@localhost mysql]# cat /root/.mysql_secret

Password set for user 'root@localhost' at 2020-04-13 06:52:51

Mar2b7g,#NWQ
[root@localhost mysql]# ln -s /usr/local/mysql/bin/mysql /usr/bin/
[root@localhost mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25

Copyright (c) 2000, 2019, 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> use mysql
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user 'root'@'localhost' identified by '1qaz@WSX';
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> select host,user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
3 rows in set (0.00 sec)

mysql> grant all privileges on . to 'root'@'%' identified by '1qaz@WSX' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)

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

mysql> grant all privileges on . to 'mysql'@'%' identified by '1qaz@WSX' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)

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

mysql> use mysql
Database changed
mysql> select host,user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| % | mysql |
| % | root |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
5 rows in set (0.00 sec)

mysql> quit;
Bye
[root@localhost mysql]# ss -atnl | grep 3306
LISTEN 0 80 :::3306 :::
[root@localhost mysql]#
[root@bogon googlebigtable]# firewall-cmd --permanent --zone=public --add-service=mysql
success
[root@bogon googlebigtable]# firewall-cmd --reload
success
[root@bogon googlebigtable]#
[root@bogon googlebigtable]# ps aux|grep mysql|awk '{print $2}'|xargs kill -9
[root@bogon googlebigtable]# /etc/init.d/mysqld start
[root@bogon googlebigtable]# netstat -apn | grep 3306
tcp6 0 0 :::3306 :::
LISTEN 12832/mysqld
unix 2 [ ] DGRAM 53306 11401/alsactl
[root@bogon googlebigtable]#

CentOS Series Notes (2)

Meng Bo, 20200411

Communication and contact: WeChat 1807479153, QQ 1807479153

Guess you like

Origin blog.51cto.com/6286393/2486980
Recommended