deepin 15.4.1 mysql_deepin15.11安装MySQL

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值