Mysql5.7.14 Linux安装

1、下载安装包 

进入mysql官网,Download MySQL Community Server  安装系统为centos6.5_64位 选择 Linux - Generic (glibc 2.5) (x86, 64-bit), Compressed TAR Archive 进行下载。

2. 解压Tar包,更改所属的组和用户

[root@iZ23tp~]# cd /usr/local/
[root@iZ23tp local]# tar -xvf  mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz

[root@iZ23tp local]# mv /usr/local/mysql-5.7.14-linux-glibc2.5-x86_64  /usr/local/mysql

[root@iZ23tp local]chown -R mysql:mysql mysql

3. 安装和初始化数据库

修改vi /etc/my.cnf 文件 [mysqld] basedir=/usr/local/mysql/   datadir=/usr/local/mysql/data

[root@iZ23tp mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

添加开机启动:执行命令cp support-files/mysql.server /etc/init.d/mysql 

4. 启动mysql服务

service mysql  start

[root@iZ23tp bin]# ./mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

修改 /etc/my.cnf 文件  socket = /tmp/mysql.sock

重启mysql服务 service mysql restart

注:mysql5.7开始,会生成一个初始化密码。

[root@iZ23tp bin]# cat /root/.mysql_secret 

# Password set for user 'root@localhost' at 2016-08-14 20:46:13 
JDGRwL?s/r4v

重新登录

[root@iZ23tp bin]# ./mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.14

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases
    -> ;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> set password = password("123456");

4. 远程连接

为了安全,默认是不允许mysql本机以外的机器访问mysql数据库服务,因此需要重新授权root 
mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

至此mysql5.7 安装成功

 

Ubuntu 16.04 安装mysql并设置远程访问

step1、安装mysql并设置root帐号密码 

apt-get install mysql-server mysql-client libmysqlclient-dev  

193921_nxh8_1777601.png

备注:可能出现无法安装情况,可尝试apt-get update

step2、查看安装完成情况

netstat -tap | grep mysql 

step3、设置mysql远程访问

vi /etc/mysql/mysql.conf.d/mysqld.cnf  注释bind-address = 127.0.0.1

mysql -uroot -proot 使用root帐号登录mysql给test用户设置权限

grant all on *.* to test@'%' identified by 'ts123' with grant option;

flush privileges;

step4、重启mysql

/etc/init.d/mysql restart 或 service mysql restart

 

 

 

 

 

转载于:https://my.oschina.net/u/1777601/blog/732532

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值