• 数据库

ubuntu16.04 安装 mysql5.7

ubuntu16.04 安装 mysql5.7 ,并配置远程访问

安装mysql及其可选组件

  • apt-get install mysql-server
  • apt-get install mysql-client
  • apt-get install libmysqlclient-dev
  • apt-get install mysql-workbench-community
  • apt-get install mysql-connector-python

查看是否安装成功

shell>netstat -tap | grep mysqld

mysql在安装完成后自动启动,root账号密码为系统root密码

mysqladmin –version 查看mysql版本

sudo service mysql status 查看mysql状态

sudo service mysql start 启动mysql服务

sudo service mysql stop 停止mysql

使用root登录mysql:

shell>mysql -u root -p

修改root账号密码:

shell>mysqladmin -u root -p password 'pwd'

或者

mysql>ALTER USER root@localhost IDENIFIED BY 'pwd'

添加其他账号并授权:

mysql>create user 'admin'@'localhost' identified by 'pwd';

mysql>grant all privileges on *.* to 'admin'@'localhost' with grant option;

指定域名,指定权限,指定database

mysql>create user 'dever'@'%.xxx.com' identified by 'pwd';

mysql>grant select,delete,drop,insert,update,create on your_database.* to 'dever'@'%.xxx.com';

查看mysql用户:

查看用户权限:

配置Mysql远程访问:

修改mysql配置文件

vi /etc/mysql/mysql.conf.d/mysqld.cnf1

把其中bind-address = 127.0.0.1注释掉:

登陆mysql修改权限

mysql>grant all on *.* to root@'%' identified by 'pwd';

flush privileges;

重启mysql:

shell>etc/init.d/mysql restart

远程访问:


相关

最新