deepin15.11安装MySQL

2020-03-06  本文已影响0人  阿杰_96c5

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
上一篇下一篇

猜你喜欢

热点阅读