zoukankan      html  css  js  c++  java
  • MariaDB管理系统

    MariaDB管理系统

    [root@c4kaichen@163 ~]# yum install mariadb
    [root@c4kaichen@163 ~]# yum install -y mariadb-server.x86_64

    开启:
    [root@c4kaichen@163 ~]# systemctl start mariadb --有报错的话删除 /var/lib/mysql 和 /etc/my.cnf 重新安装就没有错了

    设置开机自动启动该服务:
    [root@localhost ~]# systemctl enable mariadb
    Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.


    初始化设置:
    [root@c4kaichen@163 ~]# 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):
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    Enter current password for root (enter for none):
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    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.

    Set root password? [Y/n] y
    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.

    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.

    Remove test database and access to it? [Y/n] n
    ... skipping.

    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!

    防火墙对数据库进行允许策略
    [root@c4kaichen@163 ~]# firewall-cmd --permanent --add-service=mysql
    success
    [root@c4kaichen@163 ~]# firewall-cmd --reload
    success

    登录数据库:
    [root@c4kaichen@163 ~]# mysql -u root -p
    Enter password:


    查看已有数据库:

    MariaDB [(none)]> show databases;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | mysql |
    | performance_schema |
    +--------------------+
    3 rows in set (0.00 sec)


    备份数据:
    mysqldump -u root -p cisco >/tmp/package2/ciscobackup.dump

    恢复数据:

    [root@c4kaichen@163 ~]# mysql -u root -p cisco </tmp/package2/ciscobackup.dump



    解决远程主机不能连接的问题:
    [root@localhost ~]# mysql -u root -p
    MariaDB [mysql]> select * from user;
    insert into user (host,user,password) values ('172.30.2.13','root','*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B')
    > flush privileges;


    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT O
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '1*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B' WITH GRANT OPTION;

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'172.30.2.13 BY 'root' WITH GRANT OPTION;

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.100.%' IDENTIFIED BY 'my-new-password' WITH GRANT OPTION;

    ---------------------------------------------------------------------------------------------------------

    报错处理:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

  • 相关阅读:
    .net中Timer的使用
    计算日期的神器
    求全排列函数next_permutation
    各种排序
    求最大字段和
    炸弹时间复位
    最少步数,广搜
    数据
    水池数目
    最大岛屿
  • 原文地址:https://www.cnblogs.com/nodchen/p/8349546.html
Copyright © 2011-2022 走看看