网址

二进制安装MySQL_二进制安装

二进制安装MySQL_bc_02

二进制安装MySQL_linux_03


//删除默认的mariadb

[root@192 ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@192 ~]# rpm -e mariadb-libs --nodeps

//导入mysql的二进制包

[root@192 ~]# ls
anaconda-ks.cfg  mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz
[root@192 ~]# tar zxf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz  
[root@192 ~]# mv mysql-5.7.32-linux-glibc2.12-x86_64 /usr/local/mysql

//创建用户组、创建数据库目录

[root@192 ~]# groupadd -r mysql && useradd -r -g mysql -s /bin/false -M mysql
[root@192 ~]# cd /usr/local/mysql/
[root@192 mysql]# mkdir data
[root@192 mysql]# chown -R mysql:mysql .

//设置环境变量优化路径

[root@192 mysql]# tail -1 /etc/profile
export  PATH=$PATH:/usr/local/mysql/bin
[root@192 mysql]# . /etc/profile

//创建配置文件

[root@192 mysql]# cat /etc/my.cnf 
[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
server_id = 1
socket = /tmp/mysql.sock
#socket = /usr/local/mysql/mysql.sock
log-error = /usr/local/mysql/data/mysqld.err
pid-file = /usr/local/mysql/data/mysql.pid

//初始化

[root@192 mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

//配置自启动

[root@192 mysql]# cd /usr/local/mysql/support-files/
[root@192 support-files]# cp mysql.server  /etc/init.d/mysqld
[root@192 support-files]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS! 
[root@192 support-files]#  netstat -anput | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      2545/mysqld         
[root@192 support-files]# chkconfig --add mysqld
[root@192 support-files]# chkconfig --level 345 mysqld on
[root@192 support-files]# chkconfig --list

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
netconsole     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
network        	0:off	1:off	2:on	3:on	4:on	5:on	6:off

//登入并修改密码

[root@192 ~]# mysql -uroot -p`grep root@localhost /usr/local/mysql/data/mysqld.err | awk '{print $11}'`
mysql> alter user root@localhost identifide by '123.com';