deepin系统安装mysql

deepin系统安装mysql

系统信息

deepin 15.11 桌面版

64位

apt-get 源 为 阿里云

安装mysql

最好在deepin不安装其他软件的时候安装mysql,防止依赖冲突!

  1. 使用apt方式直接安装

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

  2. 设置密码

    sudo mysql -uroot -p

  3. 分别执行以下命令,注意将密码修改

    GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘这里是你的密码’ ;
    flush privileges;

  4. 登录测试

    mysql -uroot -p

无法登录

如果已经完成了上述操作,但是无法登录mysql,你需要执行以下命令:

  1. mysql身份验证过程已调用“ unix_socket”(可能与数据库到mariadb的部分迁移有关,现已删除)。要使所有内容恢复正常工作,请执行su:

    sudo su

  2. 执行以下

    /etc/init.d/mysql stop
    mysqld_safe --skip-grant-tables &
    mysql -uroot

    这将完全停止mysql,绕过用户身份验证(无需密码)并使用用户“ root”连接到mysql。

  3. 在mysql控制台中,使用mysql管理数据库:

    use mysql;

  4. 要将根密码重设为mynewpassword(根据需要更改)

    update user set password=PASSWORD(“这里是你的密码”) where User=‘root’;

  5. 覆盖身份验证方法,删除unix_socket请求(以及所有其他内容),恢复正常且有效的密码

    update user set plugin=“mysql_native_password”;

  6. 退出mysql控制台

    quit;

  7. 停止并启动与mysql有关的所有内容:

    /etc/init.d/mysql stop
    kill -9 $(pgrep mysql)
    /etc/init.d/mysql start

  8. exit su 模式

  9. 使用root登录

    mysql -u root -p

大小写敏感

  1. cd /etc/mysql/ 目录发现以下文件

    conf.d      debian-start  mariadb.conf.d  my.cnf.fallback
    debian.cnf  mariadb.cnf   my.cnf
    
  2. 需要修改 my.cnf

    sudo vi my.cnf

  3. 你可以看到以下内容

    # The MariaDB configuration file
    #
    # The MariaDB/MySQL tools read configuration files in the following order:
    # 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
    # 2. "/etc/mysql/conf.d/*.cnf" to set global options.
    # 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
    # 4. "~/.my.cnf" to set user-specific options.
    #
    # If the same option is defined multiple times, the last one will apply.
    #
    # One can use all long options that the program supports.
    # Run program with --help to get a list of available options and with
    # --print-defaults to see which it would actually understand and use.
    
    #
    # This group is read both both by the client and the server
    # use it for options that affect everything
    #
    [client-server]
    
    # Import all .cnf files from configuration directory
    !includedir /etc/mysql/conf.d/
    !includedir /etc/mysql/mariadb.conf.d/
    

    ​ 可以详细看看以上注释内容,/etc/mysql/my.cnf 是默认的总体设置,百度一大堆修改mysql大小写敏感之后,都说修改 my.cnf[mysqld]下添加啊lower_case_table_names=1.但是这个文件中并没有这个[mysqld],这很令人蛋疼…我尝试过直接添加lower_case_table_names,但是很遗憾,并没有啥用.这里就不解释我经历的过程,直接陈述解决方式.

    1. 修改my.cnf,在下面直接添加
    [mysqld]
    lower_case_table_names=1
    
    1. 然后重启mysql服务

    service mysqld start

    1. 这时候你可以登录mysql,尝试直接使用大写来查询表,如下

      mysql -uroot -p
      use demo;
      select * from DEMO_TABLE;
      select * from demo_table;
      

      如果大写报错的话,你可能需要执行

      set @lower_case_table_names=1;

      然后重试以上操作.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值