小标
2018-08-17
来源 :
阅读 1331
评论 0
摘要:本文主要向大家介绍了MySQL数据库之mysql5.7安装 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。
本文主要向大家介绍了MySQL数据库之mysql5.7安装 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。
整理一下mysql5.7的安装,安装基本与之前的mysql5.6保持一致,但是会有一些不同,来介绍一下!
整理一下安装mysql的步骤,大致如下:
解压压缩包(二进制免编译压缩包)
修改压缩包名字
创建mysql用户和用户组(组也可以不创建)
创建datadir目录
修改启动脚本文件,5.7.22版本好像没有默认配置文件。
启动mysql
安装过程如下:
#解压文件包
tar zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
#修改文件包名字并移动位置
mv mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local/mysql
#创建mysql用户
useradd -M mysql
#创建数据库目录
mkdir /data/mysql
#修改mysql目录的用户主和用户组
chown -R mysql:mysql /data/mysql
#安装mysql
[root@test3 mysql]# ./bin/mysql_install_db --user=mysql --datadir=/data/mysql
2018-07-18 19:21:28 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
#报警告提示,使用如下方式初始化
[root@test3 mysql]# ./bin/mysqld --initialize --user=mysql --datadir=/data/mysql
./bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
#安装时报错,可以使用安装如下文件包
yum -y install numactl.x86_64
#初始化如下
[root@test3 mysql]# ./bin/mysqld --initialize --user=mysql --datadir=/data/mysql
2018-07-18T11:24:17.639719Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-07-18T11:24:18.757337Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-07-18T11:24:18.939043Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-07-18T11:24:19.007577Z 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: 1c981b1a-8a7d-11e8-98d1-fa336351fc00.
2018-07-18T11:24:19.009188Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2018-07-18T11:24:19.010028Z 1 [Note] A temporary password is generated for root@localhost: ASB=D_(8zN?d
#注意最后一行,有一个临时密码设置
#拷贝启动脚本
cp -p support-files/mysql.server /etc/init.d/mysqld
#修改mysqld文件
sed -i "s/^datadir=/datadir=\/data\/mysql/" /etc/init.d/mysqld
#启动mysql
[root@test3 mysql]# service mysqld start
Starting MySQL.Logging to ‘/data/mysql/test3.err‘.
SUCCESS!
#然后进入shell交互界面
[root@test3 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
#mysql5.7要求必须更改密码,然后才可以正常使用。
mysql> alter user "root"@"localhost" identified by "123qwE#!";
Query OK, 0 rows affected (0.00 sec)
#mysql已经可以正常使用
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql>
新给定的临时密码是有一定的期限的,若过长时间不修改密码,再登录,则会出现如下错误!
[root@test1 mysql]# mysql -uroot -p
Enter password:
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
[root@test1 mysql]#
这时候可以使用mysqladmin修改密码,如下:
[root@test1 mysql]# ./bin/mysqladmin -uroot -p password
Enter password:
New password:
Confirm new password:
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@test1 mysql]#
本文由职坐标整理并发布,希望对同学们学习MySQL有所帮助,更多内容请关注职坐标数据库MySQL数据库频道!
喜欢 | 0
不喜欢 | 0
您输入的评论内容中包含违禁敏感词
我知道了

请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号