码迷,mamicode.com
首页 > 数据库 > 详细

Ubuntu 18.08 安装mysql

时间:2019-12-21 20:12:08      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:string   mat   pre   har   数据   localhost   sharp   local   mysqld   

1、安装mysql server

sudo apt-get install mysql-server

2、查看默认生成的密码

sudo cat debian.cnf

debian.cnf

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = pASsYAUR2aRiaprZX
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = pASsYAUR2aRiaprZX
socket   = /var/run/mysqld/mysqld.sock

  

3、默认用户登录 

mysql -u debian-sys-maint -p

4、修改root密码   

mysql> use mysql;
mysql> update user set authentication_string=password(‘123‘) where user=‘root‘ and Host =‘localhost‘;
mysql> update user set plugin="mysql_native_password"; 
mysql> flush privileges;
mysql> quit;

5、建立 测试用户

#创建测试用户
CREATE USER ‘demor‘@‘localhost‘ IDENTIFIED BY ‘123‘;
#创建测试数据库
CREATE DATABASE demo;
#添加权限
GRANT ALL PRIVILEGES ON  demo.* to ‘demo‘@‘localhost‘ IDENTIFIED BY ‘123‘;
#添加远程访问权限
GRANT ALL PRIVILEGES ON demo.* TO ‘demo‘@‘%‘ IDENTIFIED BY ‘123‘ WITH GRANT OPTION;
#刷新
flush privileges;

  

  

 

Ubuntu 18.08 安装mysql

标签:string   mat   pre   har   数据   localhost   sharp   local   mysqld   

原文地址:https://www.cnblogs.com/csig/p/12077928.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!