安装mysql

参照python篇一键安装lnmp。安装完之后再按照下面修改密码,修改配置文件,否则安装的时候就修改配置文件会出错。

注意:这也是二进制安装mysql。另一种二进制安装容易出错,生产环境不要用rpm包安装,会出问题,测试过安装msyql不要改里面的字符类型,否则安装时候报错。等安装完后再修改

2、查看初始化的密码:

初始化mysql时生成的密码

初始化mysql
2018-11-27T07:28:39.407117Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-11-27T07:28:40.069251Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-11-27T07:28:40.181277Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-11-27T07:28:40.194608Z 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: 0fbb7543-f216-11e8-9f31-000c29c231f7.
2018-11-27T07:28:40.195834Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-11-27T07:28:40.197256Z 1 [Note] A temporary password is generated for root@localhost: 8YuFFueq4P!o 8YuFFueq4P!o 就是密码 3、重置为复杂密码 3.1、配置免密登录 、重启mysql、登录mysql 在[mysqld]下面添加skip-grant-tables [root@ecs-03 mysql]#service mysqld stop
[root@ecs-03 mysql]# vi /etc/my.cnf
[mysqld]
skip-grant-tables   #跳过密码 重启数据库 [root@ecs-03 mysql]# systemctl restart mysqld 一条命令执行以上步骤如下 systemctl stop mysqld && sed -i '/mysqld/a skip-grant-tables' /etc/my.cnf && systemctl restart mysqld 登录数据库,下面直接回车 不用输入密码 [root@ecs-03 mysql]# mysql -u root -p
Enter password: [root@ecs-02 mysql]# 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.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> 3.2、 修改root数据库账号密码方式一(推荐) 修改当前用户为root 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> select host, user from user;
+---------------+---------------+
| host | user |
+---------------+---------------+
| % | root |
| 192.168.0.% | root |
| 192.168.0.1.% | root |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+---------------+---------------+
6 rows in set (0.00 sec) mysql> update user set host='%' where user='root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' #不用管,没有影响,直接下一步
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec) 重启数数据,否则不生效 systemctl restart mysqld #等操作完下面一起重启 授予root用户给其他用户授权的权限 update mysql.user set Grant_priv='Y' where User='root' and Host='%'; flush privileges;(刷新权限) 修改root密码、开启远程连接授权 mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec) mysql> grant all privileges on *.* TO 'root'@'%' identified by 'jenkins@123' with grant option;
Query OK, 0 rows affected, 1 warning (0.02 sec)
mysql>grant all on *.* to root@'localhost' identified by 'jenkins@123' with grant option;
mysql> alter user 'root'@'localhost' identified by 'jenkins@123';
mysql> flush privileges;
Mysql>exit 修改后把kip-grant-tables注释掉重启mysql systemctl stop mysqld && sed -i 's/skip-grant-tables/#skip-grant-tables/g' /etc/my.cnf && systemctl restart mysqld 3.3、修改root数据库账号密码方式二 mysql> set password=password("youpassword"); mysql> alter user 'root'@'localhost' identified by '';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement 报错不用管,接着输入下面 mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.02 sec) mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' identified by 'zihao@666';
Query OK, 0 rows affected, 1 warning (0.02 sec)
mysql>grant all on *.* to root@'localhost' identified by 'zihao@666';
mysql> alter user 'root'@'localhost' identified by 'zihao@666';
mysql> FLUSH PRIVILEGES; 修改后把kip-grant-tables注释掉重启mysql systemctl stop mysqld && sed -i 's/skip-grant-tables/#skip-grant-tables/g' /etc/my.cnf && systemctl restart mysqld 3.4、用修改后的密码登录mysql [root@bogon local]# mysql -u root -pzihao@666
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.22-log 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> 4、重置为简单版密码 4.1、配置免密登录 、重启mysql、登录mysql [root@ecs-03 mysql]# vi /etc/my.cnf 删掉:kip-grant-tables ,
添加:validate_password=off :可以修改成简单的密码 然后重启: [mysqld]
validate_password=off
#skip-grant-tables 4.2、修改root数据库账号密码同上 5、修改字符为utf8mb4 安装完成后需要修改字符满足生产需求,之前公司就是总是出现乱码,后来改成utf8mb4问题解决 临时修改 mysql>show variables like 'character%'; mysql>set character_set_database=utf8mb4; mysql>set character_set_server=utf8mb4; 永久修改 systemctl stop mysqld && sed -i -e 's/character-set-server = utf8/character-set-server = utf8mb4/g' -e '/client/ a\default-character-set = utf8mb4' -e '$a\default-character-set = utf8mb4' /etc/my.cnf && systemctl start mysqld 注意:character_set_database=utf8mb4 这句话不要写到配置文件里面,否则启动报错 要达到的效果 mysql> show variables like 'character%';
+--------------------------+----------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql/share/charsets/ |
+--------------------------+----------------------------------+
8 rows in set (0.01 sec)

Mysql安装、查看密码、修改密码、初始化、修改字符类型的更多相关文章

  1. ubuntu18.04下mysql安装时没有出现密码提示

    前言: 一:配置 ubuntu 18.04 mysql 5.7.30 二:问题 ubuntu18.04下mysql安装时没有出现密码提示,安装后自己有一个默认的用户名以及密码 解决方案: 1. 在终端 ...

  2. MySql安装出现问题---无服务,修改密码

           之前在项目中一直使用的是SqlServer数据库,现在学习下MySql,下面是学习MySql的学习笔记. MySql简介       MySql是一种关联数据库管理系统(关系型),将数据 ...

  3. mysql安装 以及跳过密码登录重设

    修改MySQL的登录设置: vi /etc/my.cnf 在[mysqld]的段中加上一句:skip-grant-tables 例如: [mysqld] datadir=/var/lib/mysql ...

  4. MySQL安装后设置root 密码

    Mysql安装完成后初始化root 密码为空,直接回车 使用命令行: mysqladmin -u root password "123456" 来设置root密码.这里我设置的密码 ...

  5. window系统mysql安装后获取默认密码

    未设置密码,获取默认密码方法 第一步:进去mysql根目录下,如果没有data文件夹可以新建一个,找不到my.ini文件也新建一个(在根目录下创建的my.ini,重新配置的参数会覆盖源文件的参数,所以 ...

  6. Navicat for MySQL安装之后不知道登录密码

    1,关闭你现在正在运行的mysql数据库,关闭mysql服务器. 2,关闭数据库后,运行点击开始运行,输入cmd进入命令行窗口,在这个命令行中操作进入到你数据库所在的安装路径,一般默认安装的话都会在e ...

  7. Linux MySQL 安装、远程访问和密码重置

    安装: yum install mysql yum install mysql-server yum install mysql-devel 设置开机启动: chkconfig -add mysqld ...

  8. mysql安装后改动port号password默认字符编码

    1.改动password grant all privileges on *.* to 'root'@'localhost' identified by 'new password'; 2.改动por ...

  9. mysql学习之-密码管理(默认密码,修改密码,解决忘记密码)

    1. mysql安装后默认没有密码,初始化安装后默认密码登录,需要马上修改root密码.[root@mysql ~]# cat /root/.mysql_secret    --查看root账号密码# ...

  10. mysql安装忘记初始密码怎么办

    title: MySQL安装过程忘记初始密码最简单最简单解决办法 MySQL安装过程忘记初始密码最简单解决办法 ​ 在安装MySQL的时候会给定一个初始的密码,而这个初始的密码特别恶心人一堆大小写特殊 ...

随机推荐

  1. Spring核心概念和案例

    一.Spring概念 1.Spring框架概述 轻量级的Java EE开源框架,它是由Rod Johnson为了解决企业应用程序开发的复杂性而创建, Spring框架提供了一个开发平台,用于整合其他技 ...

  2. 使用jQuery快速高效制作网页交互特效----jQuery中的事件与动画

    jQuery中的事件 和WinForm一样,在网页中的交互也是需要事件来实现的,例如tab切换效果,可以通过鼠标单击事件来实现. 事件在元素对象与功能代码中起着重要的桥梁作用. 在JQuery中,事件 ...

  3. Soda Theme sublime 自定义编辑器主题

    1.Soda ThemeSublime Text 3中较为常用的一款自定义编辑器主题,用过的人都说好.Soda Theme包含代码着色.标签.图标,拥有light和dark两种颜色主题便于用户在不同时 ...

  4. Java中实例方法和类方法的区别举例

    QAQQAQAQQQAQQAQQAQAQ import java.util.ArrayList; import java.util.Iterator; class myclass{ ; ; publi ...

  5. sql server 标量函数的用法

    函数的内容是把汉字转换成拼音 select dbo.uf_GetSpellCode( book_class) from BOOK_MSG

  6. 【转】使用 Ansible 实现数据中心自动化管理

    长久以来,IT 运维在企业内部一直是个耗人耗力的事情.随着虚拟化的大量应用.私有云.容器的不断普及,数据中心内部的压力愈发增加.传统的自动化工具,往往是面向于数据中心特定的一类对象,例如操作系统.虚拟 ...

  7. RBF、GRNN 和 PNN 神经网络在Matlab中的用法

    一.RBF神经网络 RBF神经网络概述 径向基函数神经网络 与 BP 神经网络的区别在于训练过程--其参数初始化具有一定方法,并非随机,隐含层的末尾使用了径向基函数,它的输出经过加权和得到 LW2.1 ...

  8. RSYNC @ERROR: AUTH FAILED ON MODULE XXX 解决思路及附录RSYNC常见问题及解决办法

    使用rsync往服务器上传文件时,client报如下异常: @ERROR: auth failed on module XXX rsync error: error starting client-s ...

  9. Asp.Net.Mvc+MEF+EF 项目 ,源码在GitHub ..希望对大家有所帮助

    自己开源的 一个 Asp.Net + MEF+ EF 的 项目 . 供大家学习和使用, 点击进入GitHub

  10. vue中的父组件传值给子组件

    以上父组件以及父组件里面的代码 下面是子组件以及里面的代码