首页 > 代码库 > MySQL学习笔记(一)Ubuntu16.04中MySQL安装配置

MySQL学习笔记(一)Ubuntu16.04中MySQL安装配置

 1、安装mysql

sudo apt-get install mysql-server

sudo apt-get install mysql-client

sudo apt-get install libmysqlclient-dev

2、查询是否安装成功 

sudo netstat -tap | grep mysql

如下图所示,表示安装成功

技术分享

 编辑mysql配置文件,注释掉“bind-address = 127.0.0.1”

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

#bind-address = 127.0.0.1

使用root进入mysql命令行,执行如下2个命令,示例中mysql的root账号密码:123456

 mysql -u root -p123456

技术分享

 mysql 赋给root用户权限 grant all privileges on

grant all on *.* to root@% identified by root with grant option;

flush privileges;

技术分享

刷新flush privileges;然后重启mysql,通过/etc/init.d/mysql restart命令

/etc/init.d/mysql restart  -- 重启Mysql

技术分享

 创建一个数据库:snailblog

技术分享

 创建用户:tinywan_user,并使用snailblog数据库

 grant all on snailblog.* to tinywan_user identified by test123456;

技术分享

 tinywan_user 登录后的看到的数据库

MySQL学习笔记(一)Ubuntu16.04中MySQL安装配置