zoukankan      html  css  js  c++  java
  • MySQL8.0安装

    修改文件夹名称

    $ mv mysql-8.0.4-rc-linux-glibc2.12-x86_64/ mysql
    添加默认配置文件

    $ vim/etc/my.cnf
    [client]
    port=3306
    socket=/tmp/mysql/mysql.sock

    [mysqld]
    port=3306
    user=mysql
    socket=/tmp/mysql/mysql.sock
    basedir=/usr/local/mysql
    datadir=/usr/local/mysql/data
    log-error=error.log

    /useradd -M -s /sbin/nologin mysql

    chown -R mysql.mysql /usr/local/mysql/

    cp support-files/mysql.server /etc/init.d/mysqld
    cp support-files/my-default.cnf /etc/my.cnf
    chmod +x /etc/init.d/mysqld
    chkconfig mysqld --add
    chkconfig mysqsld --list
    echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile
    . /etc/profile
    echo $PATH

    初始化mysql 会提供密码注意看

    $ /usr/local/mysql/bin/mysqld --initialize
    --user=mysql --basedir=/usr/local/mysql/
    --datadir=/usr/local/mysql/data/

    启动
    service mysqld start
    如果登陆不了修改 配置文件
    vim /etc/my.cnf
    skip-grant-tables

    service mysqld restart

    mysql

    登陆后
    use mysql;

    查看mysql 数据库的 user 表中当前 root 用户的相关信息

    执行命令为:select host,user,authentication_string,plugin from user;
    执行完命令后显示一个表格, root 用户的 host默认显示的 localhost,说明只支持本地访问,不允许远程访问。
    host: 允许用户登录的ip‘位置’%表示可以远程;

    user:当前数据库的用户名;

    authentication_string: 用户密码;在mysql 5.7.9以后废弃了password字段和password()函数;
    如果当前root用户authentication_string字段下有内容,先将其设置为空;


    use mysql;
    update user set authentication_string='' where user='root';
    3.3 退出mysql, 删除/etc/my.cnf文件最后的 skip-grant-tables 重启mysql服务;

    3.4 使用root用户进行登录,因为上面设置了authentication_string为空,所以可以免密码登录;

    mysql -u root -p
    passwrod:直接回车;
    3.5使用ALTER修改root用户密码;

    ALTER user 'root'@'localhost' IDENTIFIED BY 'Qian123#'

    更改远程权限用户连接

    执行命令为:update user set host='%' where user='root';

    刷新

    执行命令为:flush privileges;

    这样才能执行下面的语句保证%能通过
    alter user 'root'@'%' identified with mysql_native_password by 'NewPass@123'; // mysql8.0系列修改了密码验证类型,需要增加大小写数字以及特殊字符才行。

    创建用户

    $ create user 'jack'@'localhost' identified by 'Jack@WSX123';
    授予权限

    $ grant all on *.* to 'jack'@'%';
    刷新

    $ flush privileges;
    ======================================================
    修改root本地登录密码
          mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个临时的默认密码。

          [root@localhost ~]# vi /var/log/mysqld.log

          发现有一个临时密码 k>Ey>8bCws=s

          此时需要修改为自己的密码
    输入临时密码之后,

          ALTER USER 'root'@'localhost' IDENTIFIED BY 'Qigaoxiang2018@';  注意:名字必须有大写字母,数字和特殊符号

    Mysql默认不允许远程登录,所以需要开启远程访问权限

         可以先查看user表

         select user,authentication_string,host from user;

    默认都是localhost

         update user set host = '%' where user = 'root';
    此时root的host是所有都可以了
    配置默认编码为utf8
         

          修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,如下所示:

          [mysqld]

          character_set_server=utf8

          init_connect='SET NAMES utf8'

          

          

          编辑保存完 重启mysql服务;
    查看下编码:

          mysql> show variables like '%character%';

          

          可以看出已经改为utf8字符了

  • 相关阅读:
    一个新的Activity跳转到带有Framgment的Activity页面
    安卓图片下载及存储
    安卓4.0以上 UDP 发送端
    安卓 service 后台运行,activity 启动和停止service
    安卓 BaseAdapter ListView和Button
    安卓点击两次返回键退出程序
    安卓 surfaceview 添加点击事件
    Mybatis
    Cookie
    AJAX原生代码
  • 原文地址:https://www.cnblogs.com/sunju/p/11154107.html
Copyright © 2011-2022 走看看