linux 安装5.7.2版本MySQL,记录全过程

这里针对的是服务器中没有安装过mysql的,如果已经安装过的,请自行百度,查看如何删除已经存在的mysql;

1、通过wget命令下载安装包

 wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

2、下载完成后进行解压

 tar xzvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

解压完成后,可以看到当前目录下多了一个解压文件,移动该文件到/usr/local/下,并将文件夹名称修改为mysql。执行命令如下:(修改文件夹名称 mv file file2   将file 改为file2)

 mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/
 cd /usr/local/
 mv mysql-5.7.24-linux-glibc2.12-x86_64 mysql

如果/usr/local/下不存在mysql文件夹,直接执行如下命令,也可达到上述效果。

 mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql

3、在/usr/local/mysql目录下创建data目录:

mkdir /usr/local/mysql/data

4、更改mysql目录下所有的目录及文件夹所属的用户组和用户,以及权限:

useradd mysql
chown -R mysql:mysql /usr/local/mysql
chmod -R 755 /usr/local/mysql

顺序执行如下命令

5、检查该链接库文件有没有安装使用 命令进行核查(运行完上面指定,如果没有的话,需要运行下面命令进行安装)

rpm -qa|grep libaio 
yum install  libaio-devel.x86_64
yum -y install numactl

6、进入mysql的bin 目录,进行MySQL的安装,安装命令:

./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql

安装成功后,后面会有mysql登录的初始面命,一定要记住,一定要记住,一定要记住!(记录日志最末尾位置root@localhost:后的字符串,此字符串为mysql管理员临时登录密码。)

7、当5.7以上的版本,安装之后在服务器的etc目录下面将不存在my.cnf,配置文件,这里如果有需要得话,就需要我们自己创建了,这里贴出自己的配置文件

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
default-character-set=utf8
[mysqld]

character_set_server=utf8

sql_mode=PIPES_AS_CONCAT,ANSI_QUOTES,NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
datadir=/usr/local/mysql/data
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=400
innodb_file_per_table=1
#表名大小写不明感,敏感为
lower_case_table_names=1

我这里基本没有什么配置,仅仅是字符集的配置;

配置到这里就可以启动MySQL了

 

7、启动mysql命令

/usr/local/mysql/support-files/mysql.server start

8、开始进行添添加软连接,完事之后重启mysql服务

  ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql 
  ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
  service mysql restart

9、登录mysql,修改密码(密码为步骤5生成的临时密码)

mysql -u root -p

这里会出现输入密码,你需要输入当时安装成功时的初始密码

10、进行修改密码的操作(这里找了很多的命令,最终这个命令生效了)

alter user 'root'@'localhost' identified by '021227';

11、开始外部可以访问命令

grant all privileges on *.* to root@"%" identified by "lxy021227";

12、这里就可以连接外部连接工具了!

其中还有很多不足的地方,为了方便自己下一次安装的方便!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值