二进制安装MySQL

//删除默认的mariadb

[root@localhost mysql]# rpm -qa | grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@localhost mysql]# rpm -e mariadb-libs --nodeps 
[root@localhost ~]# ls
anaconda-ks.cfg  mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# tar zxf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz 
[root@localhost ~]# mv mysql-5.7.29-linux-glibc2.12-x86_64 /usr/local/mysql

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

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

//优化路径

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

//创建配置文件

vim /etc/my.cnf  查看mysql配置文件
[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@localhost mysql]#  bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

//配置自启动

[root@localhost ~]# cd /usr/local/mysql/support-files/
[root@localhost support-files]# cp mysql.server  /etc/init.d/mysqld
[root@localhost support-files]# /etc/init.d/mysqld start 
Starting MySQL. SUCCESS! 
[root@localhost support-files]# netstat -anput | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      2756/mysqld  

[root@localhost ~]# chkconfig --add mysqld  
[root@localhost ~]# chkconfig --level 345 mysqld on 
[root@localhost ~]# 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@localhost support-files]# grep password /usr/local/mysql/data/mysqld.err 
2020-11-21T11:18:07.463015Z 1 [Note] A temporary password is generated for root@localhost: Z1oS=zHGPDfW
[root@localhost support-files]# mysql -uroot -p'Z1oS=zHGPDfW'

mysql> alter user root@localhost identifide by '123.com';
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值