linux6安装mysql5.7

15 篇文章 1 订阅

1.下载mysql

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

不成功的话,则打开迅雷,复制链接自动下载
链接:https://pan.baidu.com/s/1Yjr74US0ti-Ttrr8WCSpZQ
提取码:rlqd
复制这段内容后打开百度网盘手机App,操作更方便哦
2.安装mysql

[root@localhost /]#  tar xzvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
[root@localhost /]# ls
mysql-5.7.24-linux-glibc2.12-x86_64
mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

3.移动mysql安装文件

[root@localhost /]# mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql

4.在/usr/local/mysql目录下创建data目录

[root@localhost /]# mkdir /usr/local/mysql/data

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

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

6.编译安装并初始化mysql,务必记住初始化输出日志末尾的密码(数据库管理员临时密码)

[root@localhost bin]# ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
2019-12-19T11:37:30.388348Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-12-19T11:37:30.739080Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-12-19T11:37:30.822190Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-12-19T11:37:30.890211Z 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: f0fc0e51-2253-11ea-89b8-000c29b1b67b.
2019-12-19T11:37:30.891393Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-12-19T11:37:30.893115Z 1 [Note] A temporary password is generated for root@localhost: bxfxlt<os9*R

记录日志最末尾位置root@localhost:后的字符串,此字符串为mysql管理员临时登录密码。
A temporary password is generated for root@localhost: bxfxlt<os9*R

7.编辑配置文件my.cnf,添加配置如下

[root@localhost bin]#  vi /etc/my.cnf

[mysqld]
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

8.启动mysql服务器

[root@localhost ~]# /usr/local/mysql/support-files/mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.michelle.err'.
 SUCCESS! 

9.添加软连接,并重启mysql服务

[root@localhost ~]# ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql 
[root@localhost ~]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
[root@localhost ~]# service mysql restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS! 

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

[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
mysql> set password for root@localhost=password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

11.开放远程连接

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set user.Host='%' where user.User='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

ctrl+z 退出mysql

12.设置开机自动启动

1、将服务文件拷贝到init.d下,并重命名为mysql
[root@localhost /]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
2、赋予可执行权限
[root@localhost /]# chmod +x /etc/init.d/mysqld
3、添加服务
[root@localhost /]# chkconfig --add mysqld
4、显示服务列表
[root@localhost /]# chkconfig --list

参考文章:https://www.jianshu.com/p/276d59cbc529

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

米雪唲2

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值