从mysql官网下载安装包:/mysql-5.7.20-linuxglibc2.12-x86_64.tar.gz

#切换目录
cd /usr/local
#解压下载的安装包
tar -zxvf /software/mysql/mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
#重命名
mv mysql-5.7.20-linux-glibc2.12-x86_64 mysql
#建立数据存储目录
mkdir data
#建立用户组
groupadd mysql
#建立用户,并禁止用户登录
useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql
#改变文件归属
chown -R mysql.mysql /usr/local/mysql/
#初始化系统数据库,记住不能用./bin/mysql_install_db,已经过期了
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

初始化后,会打印日志,如下 ,注意看最后输出,红色标记部分,这个就是root的临时密码。

2018-01-12T05:08:12.048923Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see doc umentation for more details).
2018-01-12T05:08:12.228535Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-01-12T05:08:12.251370Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-01-12T05:08:12.305856Z 0 [Warning] No existing UUID has been found, so we a ssume that this is the first time that this server has been started. Generating a new UUID: 968b7130-f756-11e7-8704-000c29009e57.
2018-01-12T05:08:12.306388Z 0 [Warning] Gtid table is not ready to be used. Tabl e 'mysql.gtid_executed' cannot be opened.
2018-01-12T05:08:12.307188Z 1 [Note] A temporary password is generated for root@localhost: LwchxXdoO5*8

配置数据库:

vi /etc/my.cnf

my.cnf内容:

[mysqld]
#目录设置
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306 #服务ID
socket=/tmp/mysql.sock #数据库表名大小写不敏感
lower_case_table_names=1 #设置字符集,防止中文乱码
init_connect='SET collation_connection = utf8_general_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_general_ci
skip-character-set-client-handshake
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8

安装成服务:

cp -a ./support-files/mysql.server /etc/init.d/mysqld

启动服务

service mysqld start

登录到mysql

./bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.20 Copyright (c) 2000, 2017, 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> grant all privileges on *.* to root@"%" identified by "2018dlj123!@#0112" with grant option;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

一开始想做授权,结果发现报错,原因是必须要修改初始密码。

修改初始密码:

mysql> ALTER USER USER() IDENTIFIED BY 'test123456';
Query OK, 0 rows affected (0.00 sec)

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> grant all privileges on *.* to root@"%" identified by "test123456" with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)

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

至此安装完毕!

最新文章

  1. 【实战Java高并发程序设计6】挑战无锁算法:无锁的Vector实现
  2. IIS与ASP.NET管道
  3. CI框架入门2
  4. Struts2中Action由自己与由Spring管理的区别
  5. poj3114Countries in War(缩点+DIJK)
  6. EditText 密码属性
  7. Xml序列化自引用/循环引用问题1
  8. Selenium2(webdriver)入门之TestNG的使用
  9. 更新ORACLE数据时遇到锁死情况的处理
  10. 文件打包bundle
  11. 在C#代码中应用Log4Net系列教程
  12. Docker私有仓库Registry 搭建
  13. 201521123079《java程序设计》第8周学习总结
  14. ItemCF_基于物品的协同过滤_MapReduceJava代码实现思路
  15. Apache Flink 分布式执行
  16. Mysql数据库使用量查询及授权
  17. Xamarin.Forms 自定义 TapGestureRecognizer 附加属性
  18. 20165309 《网络对抗技术》实验五:MSF基础应用
  19. div上下切换(新增、删除、上下div切换)
  20. Nginx使用教程(六):使用Nginx缓存之FastCGI缓存

热门文章

  1. ecshop ueditor实现百度编辑器
  2. [转帖]在VMware ESXi服务器上配置NAT上网 需要学习一下。
  3. [转帖]将改名贯彻到底,Xeon E3系列将改名为Xeon E
  4. SpringBoot 5.SpringBoot小知识讲解
  5. 苹果ATS 豁免摆乌龙?
  6. BZOJ4654 NOI2016国王饮水记(动态规划+三分)
  7. scheme 之门
  8. PL/SQL如何设置当前格局确保每次打开都给关闭前一样
  9. 【刷题】LOJ 6225 「网络流 24 题」火星探险问题
  10. 剖析Hadoop和Spark的Shuffle过程差异(一)