美文网首页
deepin15.11安装MySQL

deepin15.11安装MySQL

作者: 阿杰_96c5 | 来源:发表于2020-03-06 16:17 被阅读0次

    deepin15.11安装MySQL

    1. 在终端输入安装命令

    sudo apt-get install -y mysql-server mysql-client
    

    2. 安装完成后查看MySQL的默认密码,默认为空

    aj@DEEPIN:~$ sudo cat /etc/mysql/debian.cnf 
    # Automatically generated for Debian scripts. DO NOT TOUCH!
    [client]
    host     = localhost
    user     = root
    password = 
    socket   = /var/run/mysqld/mysqld.sock
    [mysql_upgrade]
    host     = localhost
    user     = root
    password = 
    socket   = /var/run/mysqld/mysqld.sock
    basedir  = /usr
    
    

    3. 按照上一步查询到的用户名和密码登录,当前为无密码登录,输入密码处直接回车

    aj@DEEPIN:~$ sudo mysql -uroot -p
    Enter password: 
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 2
    Server version: 10.1.37-MariaDB-0+deb9u1 Debian 9.6
    
    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)]> 
    
    

    MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行

    4. 设置mysql密码

     ## 启用root用户
    MariaDB [(none)]>  update mysql.user set plugin="mysql_native_password" where user="root";
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    ## 更改密码 password('root')  括号中的字符串为新密码
    MariaDB [(none)]> update mysql.user set authentication_string=password('root') where user='root' and Host ='localhost';
    Query OK, 1 row affected (0.02 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    ## 更新权限
    MariaDB [(none)]> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    

    5. 测试登录

    ## 用户名为root 密码为root 注意 -p后面没有空格
    aj@DEEPIN:~$ mysql -u root -proot
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
    Your MariaDB connection id is 5
    Server version: 10.1.37-MariaDB-0+deb9u1 Debian 9.6
    
    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)]> 
    
    

    6. mysql服务的启动与关闭

    一、 启动
    1、使用 service 启动:service mysql start
    2、使用 mysqld 脚本启动:/etc/inint.d/mysql start
    
    二、停止
    1、使用 service 启动:service mysql stop
    2、使用 mysqld 脚本启动:/etc/inint.d/mysql stop
    
    三、重启
    1、使用 service 启动:service mysql restart
    2、使用 mysqld 脚本启动:/etc/inint.d/mysql restart
    

    相关文章

      网友评论

          本文标题:deepin15.11安装MySQL

          本文链接:https://www.haomeiwen.com/subject/bnxwrhtx.html