二进制安装

1.下载https://dev.mysql.com/downloads/mysql/5.6.html#downloads

2.官方文档https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

[root@localhost local]# yum install libaio
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.aliyun.com
Package libaio-0.3.109-13.el7.x86_64 already installed and latest version
Nothing to do
[root@localhost local]# pwd
/usr/local
[root@localhost local]# tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
[root@localhost local]# ln -s mysql-5.7.22-linux-glibc2.12-x86_64 mysql
[root@localhost local]groupadd mysql
[root@localhost local] useradd -r -g mysql -s /bin/false mysql
[root@localhost local] chown -R mysql:mysql mysql
[root@localhost local]# cd mysql
[root@localhost mysql]# ll
total 40
drwxr-xr-x. 2 root root 4096 May 15 03:59 bin
-rw-r--r--. 1 7161 31415 17987 Mar 4 21:40 COPYING
drwxr-x---. 5 mysql mysql 4096 May 15 04:39 data
drwxr-xr-x. 2 root root 55 May 15 03:59 docs
drwxr-xr-x. 3 root root 4096 May 15 03:58 include
drwxr-xr-x. 5 root root 229 May 15 03:59 lib
drwxr-xr-x. 4 root root 30 May 15 03:59 man
-rw-r--r--. 1 7161 31415 2478 Mar 4 21:40 README
drwxr-xr-x. 28 root root 4096 May 15 03:59 share
drwxr-xr-x. 2 root root 90 May 15 03:59 support-files [root@localhost mysql]bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

  

[root@localhost mysql]# bin/mysql_ssl_rsa_setup  --datadir=/usr/local/mysql/data
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# vi /etc/my.cnf
[root@localhost mysql]# cat /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/
character_set_server = utf8
[root@localhost support-files]# cd ..
[root@localhost mysql]# cd bin/
[root@localhost bin]# ./mysqld_safe --user=mysql &
[1] 2942

  启动完毕

登录,修改root密码  设置远程登录

[root@localhost mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
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> set password=password("root");
Query OK, 0 rows affected, 1 warning (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> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY '......' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec) mysql> exit;

  设置开机自启

[root@localhost support-files]# cp mysql.server /etc/init.d/mysql
[root@localhost support-files]# chmod +x /etc/init.d/mysql
[root@localhost support-files]# chkconfig --add mysql
[root@localhost support-files]# chkconfig --list mysql

  

[root@localhost support-files]# service mysql stop

[root@localhost support-files]# service mysql start

配置环境变量:

[root@localhost local]# mysql -uroot -p
-bash: mysql: command not found
[root@localhost local]# ln -s /usr/local/mysql/bin/mysql /usr/bin
[root@localhost local]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.22 MySQL Community Server (GPL) 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>

mysql远程登录问题:

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 host = '%' where user = 'root';
Query OK, 0 rows affected (0.11 sec)
Rows matched: 1 Changed: 0 Warnings: 0 mysql> select host,user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| % | myuser |
| % | root |
| % | sec_user |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | sec_user |
+-----------+---------------+
6 rows in set (0.00 sec)

 

C:\Users\Administrator>mysql -u sec_user -h 192.168.222.13 -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.7.22 MySQL Community Server (GPL) Copyright (c) 2000, 2015, 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;
+--------------------+
| Database |
+--------------------+
| information_schema |
| securities_master |
+--------------------+
2 rows in set (0.00 sec) mysql> use securities_master;
Database changed
mysql> show tables;
+-----------------------------+
| Tables_in_securities_master |
+-----------------------------+
| daily_price |
| data_vendor |
| exchange |
| symbol |
+-----------------------------+
4 rows in set (0.00 sec) mysql>

  

注意:1.mysql默认的字符集是Latin ,需要修改my.cnf   设置为utf-8,

[client]
default-character-set=utf8 [mysql]
default-character-set=utf8 [mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake

  

并且重启,验证

mysql> show variables like 'character_set_database';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| character_set_database | utf8 |
+------------------------+-------+
1 row in set (0.01 sec) mysql> show variables like 'character%';
+--------------------------+----------------------------------------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql-5.7.22-linux-glibc2.12-x86_64/share/charsets/ |
+--------------------------+----------------------------------------------------------------+

2.开机启动关闭防火墙

Centos7的防火墙用firewalld.service,而不是iptable……

systemctl stop firewalld.service

systemctl disable firewalld.service

3.mysql创建用户

1)MySQL创建新用户以及ERROR 1396 (HY000)问题解决 

Assume the user is there, so drop the user 

After deleting the user, there is need to flush the mysql privileges 
Now create the user.

flush privileges;(刷新系统权限表)

每次建完用户后执行flush privileges命令

删除用户 drop user XX;

4.忘记密码进行更改

1)、关闭mysql

service mysqld stop   //linux下使用

net stop mysql    //window下使用

2)、屏蔽权限
    mysqld_safe --skip-grant-table //linux下使用

mysqld --skip-grant-table  //window下使用

3.)新开一个窗口进行密码修改

4.存在空密码新安装的

1)select host,user,password from user;查看是否空密码

2).关闭mysql
   # service mysqld stop

3).屏蔽权限
   # mysqld_safe --skip-grant-table

4)新开起一个终端输入
   # mysql -u root mysql
   mysql> delete from user where USER='';  //删除空密码
   mysql> FLUSH PRIVILEGES;
   mysql> \q

参考文档:

https://blog.csdn.net/qq_37995908/article/details/79092363

https://blog.csdn.net/ctypyb2002/article/details/79757070

https://blog.csdn.net/mengfei86/article/details/51189624

创建用户和授权

linux下mysql 5.7.22 安装的更多相关文章

  1. 08 Linux下MySQL的下载、安装及启动

    测试环境 主机系统:Win7 64位 虚拟机:VMware® Workstation 11.1.0 虚拟机系统:CentOS 6.5 64位   Kernel 2.6.32-431.e16.x86_6 ...

  2. linux下mysql的卸载、安装全过程

    卸载mysql 1.查找以前是否装有mysql 命令:rpm -qa|grep -i mysql 可以看到mysql的两个包: mysql-4.1.12-3.RHEL4.1 mysqlclient10 ...

  3. linux下mysql的源码安装

    mysql有多中安装方法,本文只涉及编译安装,对其他方法感兴趣的可以自行百度. 1.首先获取mysql软件安装包,这里用wget下载 [root@localhost ~]# wget http://d ...

  4. linux 下mysql忘记密码或者安装好linux后不知道mysql初始密码解决方案

    1.使用yum安装mysql后 2.初始密码在/var/log/mysqld.log这个文件里 3.输入命令:grep 'temporary password' /var/log/mysqld.log ...

  5. linux下mysql集群的安装

    3台redhat服务器: SQL节点(mysqld): 192.168.1.77;192.168.1.78 数据节点(ndbd): 192.168.1.77;192.168.1.78 管理节点(ndb ...

  6. [mysql] linux 下mysql 5.7.12 安装

    1.下载mysql wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.12-1.el6.x86_64.rpm-bundle.tar ...

  7. Linux下MySQL安装和配置

    --Linux下MySQL安装和配置 ---------------------------2014/05/18 Linux下MySQL的配置和安装 本文的安装采用 rpm 包安装 1.首先在官网下载 ...

  8. 【MySQL】Linux下MySQL 5.5、5.6和5.7的RPM、二进制和源码安装

      [MySQL]Linux下MySQL 5.5.5.6和5.7的RPM.二进制和源码安装 1.1  BLOG文档结构图 1.2  前言部分 1.2.1  导读和注意事项 各位技术爱好者,看完本文后, ...

  9. linux下MySQL 5.6源码安装

    linux下MySQL 5.6源码安装 1.下载:当前mysql版本到了5.6.20 http://dev.mysql.com/downloads/mysql 选择Source Code 2.必要软件 ...

随机推荐

  1. jdbc,mybatis,hibernate各自有优缺点以及区别

    JDBC: 我们平时使用jdbc进行编程,大致需要下面几个步骤: 1,使用jdbc编程需要连接数据库,注册驱动和数据库信息 2,操作Connection,打开Statement对象 3,通过State ...

  2. java强引用,软引用,弱引用,虚引用

    java强引用,软引用,弱引用,虚引用 原文:https://blog.csdn.net/liaodehong/article/details/52223354 用了Java怎么长时间一直不知道原来J ...

  3. 分数模板(C++模板)

    貌似没什么用...没有多少毒瘤题要输出分数吧... update:真的有,而且在NOIP模拟赛里出现了!写double的卡精度到怀疑人生! 可以套个兼容性比较好的高精度模板进来. #include&l ...

  4. 【bzoj1565】 NOI2009—植物大战僵尸

    http://www.lydsy.com/JudgeOnline/problem.php?id=1565 (题目链接) 题意 给出$n*m$的棋盘,僵尸攻击每个格子可以获得$v$的分数,每个格子又会保 ...

  5. centos6.5下修改文件夹权限和用户名用户组

    0.说明 Linux系统下经常遇到文件或者文件夹的权限问题,或者是因为文件夹所属的用户问题而没有访问的权限.根据我自己遇到的情况,对这类问题做一个小结. 在命令行使用命令"ll"或 ...

  6. (转)使用 Spring缓存抽象 支持 EhCache 和 Redis 混合部署

    背景:最近项目组在开发本地缓存,其中用到了redis和ehcache,但是在使用注解过程中发现两者会出现冲突,这里给出解决两者冲突的具体方案. spring-ehcache.xml配置: <?x ...

  7. 关于vue里页面的缓存

    keep-alive是vue内置的一个组件,可以使被它包含的组件处于保留状态,或避免被重新渲染. 用法: 运行结果描述: input输入框内,路由切换输入框内部的内容不会发生改变. 在keep-ali ...

  8. 利用千人基因组数据库查看SNP在不同地区、国家、洲的频率及个数

    首先,进入千人基因组数据库的网站:https://www.ncbi.nlm.nih.gov/variation/tools/1000genomes/ 如下图所示,在数据库的框框里输入我们感兴趣的SNP ...

  9. Pentaho data integration(kettle) 在Mac上启动不了

    环境 MacOS Mojave (10.14.1) Pentaho Data Integration 8.2 Java 8 现象 从官方下载下来最新的安装包,解压之后,双击Data Integrati ...

  10. git中如何切换分支,拉取分支,合并分支

    idea中如何使用git来做分支的切换合并: https://blog.csdn.net/autfish/article/details/52513465 本地分支与远程分支: https://seg ...