• mysql8.0.13安装


    1. 检查是否有安装mysql,有就删除

    rpm安装查看:rpm -qa | grep mysql
    dpkg安装查看:dpkg-l|grep mysql
    yum安装查看:yum list installed | grep mysql
    源码安装查看:查看是否有mysql文件

    2. 下载最新版mysql

    https://dev.mysql.com/downloads/mysql/
    选择Linux Generic通用版和Compressed TAR Archive压缩源码,选择不登陆直接下载

    3. 解压重命名

    tar -zxvf  *.tar.gz
    tar -xvJf  *.tar.xz  // 一般后缀为这个解压
    mv * mysql  // *为文件名

    4. 添加组和用户并创建存储文件夹

    groupadd mysql  // 添加组
    useradd -r -g mysql mysql  // 为组添加用户
    mkdir /app/software/mysql_data // 创建数据存储文件夹

    5. 初始化mysql

    ./bin/mysqld  --user=mysql --lower-case-table-names=1 --initialize-insecure --basedir=/app/source/mysql --datadir=/app/software/mysql_data
    # 使用mysql用户权限进行初始化,并设置数据读写忽略大小写,初始化密码为空,和确定初始化mysql文件夹于存储文件夹
    # 如报错libaio.so.1, 则:yum install libaio

    6. 修改配置/etc/my.cnf

    [mysqld]
    server-id                      = 1
    user                = mysql #指定用户,使用配置启动安全需求
    port
    = 3306 mysqlx_port = 33060 mysqlx_socket = /tmp/mysqlx.sock datadir = /app/software/mysql_data socket = /tmp/mysql.sock pid-file = /tmp/mysqld.pid log-error = error.log #默认mysql_data目录 slow-query-log = 1 slow-query-log-file = slow.log long_query_time = 0.2 log-bin = bin.log relay-log = relay.log binlog_format = ROW relay_log_recovery = 1 character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci init_connect = 'SET NAMES utf8mb4' innodb_buffer_pool_size = 1G join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M log_timestamps = SYSTEM lower_case_table_names = 1 default-authentication-plugin = mysql_native_password

    7. 更改权限,添加服务

    chown -R mysql:mysql /app/software/mysql_data #修改所有者
    chmod -R 777 /app/software/mysql_data #增加权限 .
    /support-files/mysql.server文件中修改: basedir=/app/source/mysql datadir=/app/software/mysql_data cp -a ./support-files/mysql.server /etc/init.d/mysql #添加服务

    service mysql start/stop/restart #测试启动,如报错,查看error.log,根据错误提示解决

    8. 设置全局

    修改/etc/profile文件,在export PATH...上面:
    #set for mysql
    export MYSQL_HOME=/app/mysql
    export PATH=$PATH:$MYSQL_HOME/bin
    
    刷新配置source /etc/profile

    9. 开机启动

    # 设置开机启动
    touch /usr/lib/systemd/system/mysql.service
    
    [Unit]
    Description=mysql
    After=network.target
    After=syslog.target
    
    [Service]
    User=mysql
    Group=mysql
    ExecStart
    =/app/source/mysql/bin/mysqld --defaults-file=/etc/my.cnf LimitNOFILE = 5000 #Restart=on-failure #RestartPreventExitStatus=1 #PrivateTmp=false [Install] WantedBy=multi-user.target

    systemctl start/stop/restart mysql.service #启动服务
    systemctl enable mysql.service #设为开机启动

     10 新增用户和权限

    use mysql;
    
    create user username identified by 'password';
    
    select host, user from user;
    
    show grants for username;
    
    grant all on 数据库.* to 'username'@'%';
    
    flush privileges;
  • 相关阅读:
    IE8,IE10下载的临时文件到哪里去了???
    安全退出,清空Session或Cookie
    删掉SQL Server登录时登录名下拉列表框中的选项
    C#中==、Equals、ReferenceEquals的区别
    [转载]C#中as和is关键字的用法
    HTML5权威指南 5.绘制图形
    HTML5权威指南 3.HTML5的结构
    HTML5权威指南 2.HTML5与HTML4的区别
    HTML5权威指南 1.Web时代的变迁
    web前端黑客技术揭秘 9.Web蠕虫
  • 原文地址:https://www.cnblogs.com/maoriaty/p/10019481.html
Copyright © 2020-2023  润新知