mysql进阶
1. 二进制格式mysql安装
**//下载二进制格式的mysql软件包**
[root@yanlei src]# wget https://downloads.mysql.com/archives/get/file/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
[root@yanlei src]# ls
debug mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
kernels
**//创建用户和组**
[root@yanlei src]# groupadd -r -g 306 mysql
[root@yanlei src]# useradd -r -M -s /sbin/nologin -u 306 -g 306 mysql
**//解压软件至/usr/src**
[root@yanlei src]# tar -xf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
[root@yanlei src]# ls
debug mysql-5.7.30-linux-glibc2.12-x86_64
**//做软链接**
[root@yanlei src]# ln -s mysql-5.7.30-linux-glibc2.12-x86_64 mysql
[root@yanlei src]# ll
total 644552
drwxr-xr-x. 2 root root 6 Apr 11 2018 debug
drwxr-xr-x. 2 root root 6 Apr 11 2018 kernels
lrwxrwxrwx. 1 root root 35 Jun 13 20:03 mysql -> mysql-5.7.30-linux-glibc2.12-x86_64
**//修改目录/usr/src/mysql的属主属组**
[root@yanlei src]# chown -R mysql.mysql mysql*
[root@yanlei src]# ll
total 644552
drwxr-xr-x. 2 root root 6 Apr 11 2018 debug
drwxr-xr-x. 2 root root 6 Apr 11 2018 kernels
lrwxrwxrwx. 1 mysql mysql 35 Jun 13 20:03 mysql -> mysql-5.7.30-linux-glibc2.12-x86_64
drwxr-xr-x. 9 mysql mysql 129 Jun 13 20:00 mysql-5.7.30-linux-glibc2.12-x86_64
**//添加环境变量**
[root@yanlei ~]# cat /etc/profile.d/mysql.sh
export PATH=/usr/src/mysql/bin:$PATH
[root@yanlei ~]# . /etc/profile.d/mysql.sh
[root@yanlei ~]# echo $PATH
/usr/src/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
**//建立数据存放目录**
[root@yanlei ~]# mkdir /mysqldata
[root@yanlei ~]# chown -R mysql.mysql /mysqldata
[root@yanlei ~]# ll /
total 16
lrwxrwxrwx. 1 root root 7 Jun 13 02:04 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Jun 13 02:14 boot
drwxr-xr-x. 20 root root 3220 Jun 13 18:03 dev
drwxr-xr-x. 75 root root 8192 Jun 13 20:18 etc
drwxr-xr-x. 2 root root 6 Apr 11 2018 home
lrwxrwxrwx. 1 root root 7 Jun 13 02:04 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Jun 13 02:04 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 Apr 11 2018 media
drwxr-xr-x. 2 root root 6 Apr 11 2018 mnt
drwxr-xr-x. 2 mysql mysql 6 Jun 13 20:26 mysqldata
**//初始化数据库**
[root@yanlei ~]# mysqld --initialize --user=mysql --datadir=/mysqldata
2020-06-13T12:31:05.313301Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-06-13T12:31:05.313508Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2020-06-13T12:31:05.565998Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-06-13T12:31:05.615276Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-06-13T12:31:05.711019Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: c0488828-ad71-11ea-814e-000c2936c699.
2020-06-13T12:31:05.727432Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-06-13T12:31:06.840120Z 0 [Warning] CA certificate ca.pem is self signed.
2020-06-13T12:31:06.964329Z 1 [Note] A temporary password is generated for root@localhost: 5#op=oCdLAqt
[root@yanlei ~]# echo ' 5#op=oCdLAqt'>pass
[root@yanlei ~]# ls
anaconda-ks.cfg pass