Ubuntu 18.04 安装mysql

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;

  

  

 

posted @ 2019-12-21 19:09  csig  阅读(401)  评论(0编辑  收藏  举报