一、创建相关用户和目录
[root@MySQL8-SmallA ~]# groupadd -g 500 mysql
[root@MySQL8-SmallA ~]# useradd -u 501 -g mysql -d /home/mysql mysql
[root@MySQL8-SmallA ~]# mdkir -p /soft /data/mysql /data/log /log
[root@MySQL8-SmallA ~]# chown mysql.mysql -R /soft
[root@MySQL8-SmallA ~]# chown mysql.mysql -R /data/mysql
[root@MySQL8-SmallA ~]# chown mysql.mysql -R /data/log
[root@MySQL8-SmallA ~]# chown mysql.mysql -R /log
[root@MySQL8-SmallA ~]# chown mysql.mysql -R /home/mysql
二、初始化
[mysql@MySQL8-SmallA ~]$ tar -zxvf mysql-8.0.21-el7-x86_64.tar.gz
[mysql@MySQL8-SmallA ~]$ ls
mysql-8.0.21-el7-x86_64 mysql-8.0.21-el7-x86_64.tar.gz
[mysql@MySQL8-SmallA ~]$ mv mysql-8.0.21-el7-x86_64 mysql8.0
[mysql@MySQL8-SmallA ~]$
[mysql@MySQL8-SmallA ~]$
[mysql@MySQL8-SmallA ~]$ ls
mysql8.0 mysql-8.0.21-el7-x86_64.tar.gz
[mysql@MySQL8-SmallA ~]$ cd mysql8.0/
[mysql@MySQL8-SmallA mysql8.0]$ ls
bin docs include lib LICENSE man README share support-files
[mysql@MySQL8-SmallA mysql8.0]$ ./bin/mysqld --defaults-file=/home/mysql/my.cnf --basedir=/home/mysql/mysql8.0/ --datadir=/data/mysql/ --user=mysql --initialize-insecure
[mysql@MySQL8-SmallA mysql8.0]$
[mysql@MySQL8-SmallA log]$ cat mysql-error.log
2020-11-16T16:56:09.479960+08:00 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 10000)
2020-11-16T16:56:09.479984+08:00 0 [Warning] [MY-010141] [Server] Changed limits: max_connections: 214 (requested 2000)
2020-11-16T16:56:09.479993+08:00 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 400 (requested 2048)
2020-11-16T16:56:09.480711+08:00 0 [System] [MY-013169] [Server] /home/mysql/mysql8.0/bin/mysqld (mysqld 8.0.21) initializing of server in progress as process 41363
2020-11-16T16:56:09.492193+08:00 0 [Warning] [MY-012364] [InnoDB] innodb_open_files should not be greater than the open_files_limit.
2020-11-16T16:56:09.492442+08:00 0 [Warning] [MY-013267] [InnoDB] The setting INNODB_UNDO_TABLESPACES is deprecated and is no longer used. InnoDB always creates 2 undo tablespaces to start with. If you need more, please use CREATE UNDO TABLESPACE.
2020-11-16T16:56:09.496328+08:00 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-11-16T16:56:11.069100+08:00 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-11-16T16:56:12.667571+08:00 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
三、启动MySQL
[mysql@MySQL8-SmallA mysql8.0]$ ./bin/mysqld_safe --defaults-file=/home/mysql/my.cnf --datadir=/data/mysql --user=mysql &
[mysql@MySQL8-SmallA mysql8.0]$ jobs
[1]+ 运行中 ./bin/mysqld_safe --defaults-file=/home/mysql/my.cnf --datadir=/data/mysql --user=mysql &
[mysql@MySQL8-SmallA mysql8.0]$
[mysql@MySQL8-SmallA mysql8.0]$
[mysql@MySQL8-SmallA mysql8.0]$ ps -ef | grep mysql
root 37831 1704 0 14:33 ? 00:00:00 sshd: mysql [priv]
mysql 37837 37831 0 14:33 ? 00:00:01 sshd: mysql@pts/2,pts/3
mysql 37840 37837 0 14:33 pts/2 00:00:01 -bash
mysql 39030 37837 0 15:01 pts/3 00:00:00 -bash
mysql 42102 39030 0 17:04 pts/3 00:00:00 tail -f /data/mysql/MySQL8-SmallA.localdomain.err
mysql 42111 37840 0 17:05 pts/2 00:00:00 /bin/sh ./bin/mysqld_safe --defaults-file=/home/mysql/my.cnf --datadir=/data/mysql --user=mysql
mysql 43263 42111 10 17:05 pts/2 00:00:03 /home/mysql/mysql8.0/bin/mysqld --defaults-file=/home/mysql/my.cnf --basedir=/home/mysql/mysql8.0 --datadir=/data/mysql --plugin-dir=/home/mysql/mysql8.0/lib/plugin --log-error=/log/mysql-error.log --pid-file=/data/mysql.pid --socket=/tmp/mysql3306.sock --port=3306
mysql 43321 37840 0 17:05 pts/2 00:00:00 ps -ef
mysql 43322 37840 0 17:05 pts/2 00:00:00 grep --color=auto mysql
---启动成功
四、连接MySQL
[mysql@MySQL8-SmallA ~]$ ./mysql8.0/bin/mysql -u root -S /tmp/mysql3306.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.21 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> exit
五、修改密码 同MySQL5.7不同
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> alter user 'root'@'localhost' identified with mysql_native_password by 'mysql123';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
5.7修改密码
update user set password=password('mysql123') where user= 'root'
flush privileges;
多年不碰MySQL一些基本知识已经全都忘了,重新回炉记录一下MySQL基本理论和操作。
--end