linux 安装mysql

    1. 单实例安装

 

cp /soft/mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz  /usr/local/

 

解压mysql到/usr/local目录

 

解压:

tar -zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz

 

安装需要的依赖

yum install -y libaio

 

具体安装

shell> groupadd mysql

shell> useradd -r -g mysql mysql

shell> cd /usr/local

shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz

shell> ln -s full-path-to-mysql-VERSION-OS mysql

shell> cd mysql

shell> mkdir mysql-files

shell> chmod 770 mysql-files

shell> chown -R mysql .

shell> chgrp -R mysql .

shell> bin/mysqld --initialize --user=mysql     # MySQL 5.7.6 and up

记住初始化产生的密码

password  a generated for root@localhost:MYy.)hutk1_c

shell> bin/mysql_ssl_rsa_setup              # MySQL 5.7.6 and up

shell> chown -R root .

shell> chown -R mysql data mysql-files

shell> bin/mysqld_safe --user=mysql &

# Next command is optional

shell> cp support-files/mysql.server /etc/init.d/mysql.server //复制配置到指定地方 用于配置开机启动

 

设置开机启动

Chkconfig --list  查看开机启动项目

Chkconfig mysql.server on     配置mysql开机启动

 

配置环境变量:/etc/profile 里面 最后export PATH=/usr/local/mysql/bin:$PATH

 

然后重新加载该文件   source /etc/profile

 

 

登陆,修改密码

set password = 'root1234%';

 

允许远程登陆

 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root1234%'

 

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root1234%' WITH GRANT  OPTION;

flush privileges;  

 

这种方法并不适用于Mysql 8.0以后的版本,

 

  1. CREATE USER 'root'@'%' IDENTIFIED BY '你的密码';
  2. GRANT ALL ON *.* TO 'root'@'%';
  3. ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';
  4. flush privileges;  

 

 

启动的时候可能会报错

 

这是因为mysql启动的时候需要配置文件,而在安装centos的时候,哪怕是mini版本都会有个默认的配置在/etc目录中

/usr/local/mysql/bin/mysqld --verbose --help |grep -A 1 'Default options'

Default options are read from the following files in the given order:

/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

 

Mysql启动的时候会以上面所述的顺序加载配置文件

 

如果报错,先重命名my.cnf文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值