zoukankan      html  css  js  c++  java
  • 【MySQL】Mariadb安装

    Mariadb安装

    1.解压

    [root@oradb bin]# tar zxvf mariadb-10.3.18-linux-x86_64.tar.gz
    [root@oradb bin]# mv mariadb-10.3.18-linux-x86_64 /usr/local/
    [root@oradb bin]# cd /usr/local/
    [root@oradb local]# mv mariadb-10.3.18-linux-x86_64/ mysql/
    

    2.新建mysql用户

    groupadd mysql
    useradd -g mysql mysql
    
    chown mysql:mysql -R /usr/local/mysql
    

    3.新建数据库目录

    mkdir -p /u01/data
    chown mysql:mysql -R /u01/data
    

    4.初始化数据库

    scripts/mysql_install_db --user=mysql --datadir=/u01/data
    

    5.查看my.cnf执行的顺序.

    [root@oradb support-files]# /usr/local/mysql/bin/mysqld --verbose --help |grep -A 1 'Default options'
    2019-09-23 15:25:07 0 [Note] Plugin 'FEEDBACK' is disabled.
    2019-09-23 15:25:07 0 [Warning] Could not open mysql.plugin table. Some options may be missing from the help text
    Default options are read from the following files in the given order:
    /etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf 
    

    顺序为/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf

    也可以用如下命令查找:

    [root@oradb support-files]# locate my.cnf
    /etc/my.cnf
    

    6.修改my.cnf

    [root@oradb support-files]# vi /etc/my.cnf 
    [mysqld]
    datadir=/u01/data/
    socket=/tmp/mysql.sock
    user=mysql
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    
    [mysqld_safe]
    log-error=/u01/data/mysqld.log
    pid-file=/tmp/mysqld.pid
    

    7.生成自启动脚本

    [root@oradb mysql]# cp support-files/mysql.server /etc/init.d/mysqld
    [root@oradb mysql]# vi /etc/init.d/mysqld 
    ###修改data目录
    datadir=/u01/data
    [root@oradb mysql]# chkconfig --add mysqld
    [root@oradb mysql]# chkconfig mysqld on
    

    错误

    [root@oradb mysql]# service mysqld start
    Starting MariaDB.190923 15:36:00 mysqld_safe Logging to '/u01/data/mysqld.log'.
    190923 15:36:00 mysqld_safe Starting mysqld daemon with databases from /u01/data/
     SUCCESS! 
    [root@oradb mysql]# tail -f /u01/data/mysql.log
    tail: cannot open `/u01/data/mysql.log' for reading: No such file or directory
    tail: no files remaining
    
    
    [root@oradb data]# ls -l mysqld.log 
    -rw-rw----. 1 mysql mysql 1880 Sep 23 15:36 mysqld.log
    [root@oradb data]# chmod 777 mysqld.log 
    [root@oradb data]# service mysqld restart
    
    [root@oradb data]# tail -f /u01/data/mysqld.log 
    2019-09-23 15:37:28 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
    2019-09-23 15:37:28 0 [Note] InnoDB: 10.3.18 started; log sequence number 1630824; transaction id 21
    2019-09-23 15:37:28 0 [Note] InnoDB: Loading buffer pool(s) from /u01/data/ib_buffer_pool
    2019-09-23 15:37:28 0 [Note] Plugin 'FEEDBACK' is disabled.
    2019-09-23 15:37:28 0 [Note] InnoDB: Buffer pool(s) load completed at 190923 15:37:28
    2019-09-23 15:37:28 0 [Note] Server socket created on IP: '::'.
    2019-09-23 15:37:28 0 [Note] Reading of all Master_info entries succeeded
    2019-09-23 15:37:28 0 [Note] Added new Master_info '' to hash table
    2019-09-23 15:37:28 0 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
    Version: '10.3.18-MariaDB'  socket: '/tmp/mysql.sock'  port: 3306  MariaDB Server
    
    

    8.修改环境变量

    [root@oradb data]# vi /etc/profile
    export PATH=/usr/local/mysql/bin:$PATH
    [root@oradb data]# source /etc/profile
    

    9.mysql 安全配置

    [root@oradb data]# mysql_secure_installation
    
    NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
          SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
    
    In order to log into MariaDB to secure it, we'll need the current
    password for the root user.  If you've just installed MariaDB, and
    you haven't set the root password yet, the password will be blank,
    so you should just press enter here.
    
    Enter current password for root (enter for none): 
    OK, successfully used password, moving on...
    
    Setting the root password ensures that nobody can log into the MariaDB
    root user without the proper authorisation.
    
    ##是否设置root用户密码
    Set root password? [Y/n] Y 
    ##新的root密码
    New password: 
    Re-enter new password: 
    Password updated successfully!
    Reloading privilege tables..
     ... Success!
    
    
    By default, a MariaDB installation has an anonymous user, allowing anyone
    to log into MariaDB without having to have a user account created for
    them.  This is intended only for testing, and to make the installation
    go a bit smoother.  You should remove them before moving into a
    production environment.
    
    ##  是否删除匿名用户
    Remove anonymous users? [Y/n] Y
     ... Success!
    
    Normally, root should only be allowed to connect from 'localhost'.  This
    ensures that someone cannot guess at the root password from the network.
    
    ## 是否禁止root远程登录
    Disallow root login remotely? [Y/n] Y
     ... Success!
    
    By default, MariaDB comes with a database named 'test' that anyone can
    access.  This is also intended only for testing, and should be removed
    before moving into a production environment.
    
    ## 是否删除test数据库
    Remove test database and access to it? [Y/n] Y
     - Dropping test database...
     ... Success!
     - Removing privileges on test database...
     ... Success!
    
    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.
    
    ## 是否重新加载权限表
    Reload privilege tables now? [Y/n] Y
     ... Success!
    
    Cleaning up...
    
    All done!  If you've completed all of the above steps, your MariaDB
    installation should now be secure.
    
    Thanks for using MariaDB!
    

    10.进入mysql

    [root@oradb data]# mysql -uroot -predhat
    Welcome to the MariaDB monitor.  Commands end with ; or g.
    Your MariaDB connection id is 19
    Server version: 10.3.18-MariaDB MariaDB Server
    
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    MariaDB [(none)]> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    +--------------------+
    3 rows in set (0.001 sec)
    
    
  • 相关阅读:
    杂项收集,包括-发邮件、二维码生成、文件下载、压缩、导出excel
    SQL2008删除大量数据
    优秀程序设计的18大原则
    多线程基础
    SQL金典
    [读书笔记]高效程序员的45个习惯:敏捷开发修炼之道
    Unity 查找资源引用工具
    Unity自动生成各种机型分辨率效果工具
    Unity Editor模式 Invoke()函数 失效
    Unity 特效 粒子 自动播放
  • 原文地址:https://www.cnblogs.com/zhangshengdong/p/11724984.html
Copyright © 2011-2022 走看看